Pages: 1 2 3 4 5 6 7
Author Topic: In need of a Sonic fangame engine for Enigma  (481,972 Views)
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #30 Posted on: October 23, 2014, 01:02:03 PM
I haven't looked at the example, does it happen to use inheritance? We've had issues with script locals for a while, I am not sure what could have changed off hand.
Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
Reply #31 Posted on: October 23, 2014, 04:16:22 PM
Ohh I presume it's because of a parser change then.

It's called like this:

with (Player)
{
  collision_onset(other.id);  //other.id being the id of the collectable like a ring or box or whatever
}


// collision_onset
// Checks if there is going to be a collision with the object giving in argument0 given the Player's current speed
// To be accurate it does this using a place_meeting check at the position the Player will be at given it's hspeed / vspeed
// And also using two collision lines either side of the player mask from the Player's current position to the position it
// will be at given it's hspeed / vspeed

var x1, y1, x2, y2;

x1 = x + cos(full_direction+pi/2)*mask_radius; y1 = y - sin(full_direction+pi/2)*mask_radius;
x2 = x + cos(full_direction-pi/2)*mask_radius; y2 = y - sin(full_direction-pi/2)*mask_radius;

return (place_meeting(x + full_hspeed, y + full_vspeed, other.id)
        || collision_line(x1, y1, x1 + full_hspeed, y1 + full_vspeed, argument0, false, true) != noone
        || collision_line(x2, y2, x2 + full_hspeed, y2 + full_vspeed, argument0, false, true) != noone)

So the script is using local variables for Player; ie full_direction,  full_hspeed, full_vspeed

The parser is notorious for breaking with things like this.
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #32 Posted on: October 23, 2014, 08:23:30 PM
Looks like the issue is with the with() construct. Polygone, can you explain exactly why we don't have working locals in scripts? I am not too informed on the matter, but I've been aware of its existence.
Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
Reply #33 Posted on: October 24, 2014, 12:22:37 PM
Quote from: Robert B Colton on October 23, 2014, 08:23:30 PM
Looks like the issue is with the with() construct. Polygone, can you explain exactly why we don't have working locals in scripts? I am not too informed on the matter, but I've been aware of its existence.
Cause Josh do wrong? <_<
Offline (Unknown gender) HitCoder

Member
Joined: Aug 2014
Posts: 157
View profile WWW
Reply #34 Posted on: October 24, 2014, 08:41:22 PM
I've done a temporary workaround for while a solution is found, or enigma is fixed, but anyway, why does sonic go at a different speed on hitting a spring depending on his current speed - I mean, the harder he hits a spring, the faster he goes or whatever? How can I fix this?
Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
Reply #35 Posted on: October 25, 2014, 01:58:18 PM
Quote from: HitCoder on October 24, 2014, 08:41:22 PM
I've done a temporary workaround for while a solution is found, or enigma is fixed, but anyway, why does sonic go at a different speed on hitting a spring depending on his current speed - I mean, the harder he hits a spring, the faster he goes or whatever? How can I fix this?
This also happens in classic Sonic games, perhaps not to the same degree though.

The code for the springs is in SpringParent begin step event:

        // Get the hspeed and vspeed which the player will be set to (note this is dependent on the original player's speed)
        hspd_set = (abs(full_hspeed*other.bounce_factor) + other.strength)*other.dcos + (abs(full_vspeed)*other.dcos + full_hspeed*abs(other.dsin))*abs(other.dsin);
        vspd_set = (abs(full_vspeed*other.bounce_factor) + other.strength)*other.dsin + (abs(full_hspeed)*other.dsin - full_vspeed*abs(other.dcos))*abs(other.dsin);
Offline (Unknown gender) HitCoder

Member
Joined: Aug 2014
Posts: 157
View profile WWW
Reply #36 Posted on: October 25, 2014, 02:34:21 PM
Yea, I realise that code was there, but I don't remember it working quite like that on the classic games... I thought you could keep momentum on the axis the spring isn't bouncing you on.
Also, Polygone, is there a way to fix the 90-degree rotation snapping bug? It seems quite common in your engine...
I mean where you go up a slope, expecting to go into the air, but then it rotates you almost a whole 90 degrees and makes you snap to the floor. I know it's normal in some sonic engines, but it's not supposed to be there. Lol.
Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
Reply #37 Posted on: October 25, 2014, 03:12:44 PM
Quote from: HitCoder on October 25, 2014, 02:34:21 PM
Yea, I realise that code was there, but I don't remember it working quite like that on the classic games... I thought you could keep momentum on the axis the spring isn't bouncing you on.
It does in my engine?

Also, Polygone, is there a way to fix the 90-degree rotation snapping bug? It seems quite common in your engine...
Well it's technically a bug which of course could be fixed somehow but I'm not going to make any attempt to do so lol.
Offline (Unknown gender) HitCoder

Member
Joined: Aug 2014
Posts: 157
View profile WWW
Reply #38 Posted on: October 26, 2014, 03:34:43 AM
I accidentally deleted this post, refreshed the page, and thought it had double posted. Whoops.

Anyway, I've got it all fixed, I was just wondering if I could build an engine using your's as a base? I will give credit if you don't mind me making my own based on yours, but if you'd rather I didn't spin-off your engine, then that's fine. I was just wondering.

Also, when I said keep your momentum on the non-modified axis, your engine seems to cap the speed, but I cannot find a way around this :/
Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
Reply #39 Posted on: October 26, 2014, 11:26:14 AM
You can do whatever you like with it, I developed the engine from another engine myself.

It's optional, but if you wish to then you can give credit to:
- Damizean & McdIzzY (for the original slope engine)
- Kain (for the boxes in his Sonic 3 engine)
- Flexaplex (for this engine).
Offline (Unknown gender) HitCoder

Member
Joined: Aug 2014
Posts: 157
View profile WWW
Reply #40 Posted on: October 26, 2014, 02:22:20 PM
Ok, thank you Polygone. I also think this thread can be closed now, but I won't just yet unless someone else has something to say. I think I might close it if it's inactive for around 2 weeks. Thank you all for your help. :)

~~HitCoder~~
Offline (Unknown gender) HitCoder

Member
Joined: Aug 2014
Posts: 157
View profile WWW
Reply #41 Posted on: October 26, 2014, 09:31:00 PM
I just saved a file in Enigma, but when I did, Enigma randomly closed. When I try to open the file, it says it's corrupted, so... fix bug please?
Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
Reply #42 Posted on: October 26, 2014, 09:39:10 PM
Well I've done some debugging on the issue with the local variables being called in scripts, the problem is actually the with statement scoping being messed up inside if statements.

My test, in obj_1:

with (obj_0)
{
scr_0();
}

In this case local variables in scr_0 are used from obj_0 as they should be.

with (obj_0)
{
if (scr_0()) {}
}

In this case local variables in scr_0 are used from obj_1 incorrectly.

Example file: https://app.box.com/s/n0p8ccr75hticpcs545r
Offline (Unknown gender) TheExDeus

Developer
Joined: Apr 2008
Posts: 1,860
View profile
Reply #43 Posted on: October 26, 2014, 09:41:16 PM
You could of checked the generated .cpp files and probably see that. Sorlok was the one who changed scoping recently. Maybe he can fix it.
Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
Reply #44 Posted on: October 27, 2014, 08:25:00 AM
This is the cpp gen:

  {
    with((obj_0))
    {
      :: scr_0();
     
    }
   
  }
  ;


  {
    with((obj_0))
    {
      if((scr_0()))
      {
       
      }
   
    }
  }
  ;

   
Pages: 1 2 3 4 5 6 7