Skip to content

Commit 081c136

Browse files
committed
Improved parity between framerates
Renamed Delta variable and everything should look the same between framerates
1 parent 281da6c commit 081c136

File tree

11 files changed

+71
-44
lines changed

11 files changed

+71
-44
lines changed

Platform82.gm82/objects/objCamera.gml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ applies_to=self
2323
camLag = max(camLag - 1, 0)
2424
if (camLag == 0)
2525
{
26-
x = floor(lerp(x, camTarget.x + camXShift, 0.2*global.idDelta));
27-
y = floor(lerp(y, camTarget.y, 0.2*global.idDelta));
26+
x = floor(lerp(x, camTarget.x + camXShift, 0.2*global.delta));
27+
y = floor(lerp(y, camTarget.y + camYShift, 0.2*global.delta));
2828

29-
camXShift = scrApproach(camXShift, (round(-(round(camTarget.xprevious - camTarget.x)*2)/2)*16), 1);
29+
camXShift = inch(camXShift, (round(-(round((camTarget.xprevious - camTarget.x) / global.delta)/3)*3)*16), 1*global.delta);
3030
}

Platform82.gm82/objects/objCannon.gml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ applies_to=self
2929
if (state = 0)
3030
{
3131
// -- Rotate the object towards a target angle
32-
image_angle = lerp(image_angle, 120 * image_xscale, 0.05)
32+
image_angle = lerp(image_angle, 120 * image_xscale, 0.05*global.delta)
3333
// -- Check if the object is near an interactable object with the same angle
3434
if (place_meeting(x, y, parInteractable) && scrRoundNearMultiple(image_angle, 22.5) == scrRoundNearMultiple(120 * image_xscale, 22.5))
3535
{
@@ -47,19 +47,19 @@ applies_to=self
4747
if (state == 1)
4848
{
4949
// -- Increase the rotation time
50-
rotateTime += 3;
50+
rotateTime += 3*global.delta;
5151

5252
if (rotateTime < 310)
5353
{
5454
// -- Rotate cannon to face the launch direction
55-
image_angle = scrApproach(image_angle, dcos(rotateTime) * 90* image_xscale, 5);
55+
image_angle = scrApproach(image_angle, dcos(rotateTime) * 90* image_xscale, 5*global.delta);
5656
objectIndex.x = x + dcos(image_angle + 90)*12;
5757
objectIndex.y = y - dsin(image_angle + 90)*12;
5858
}
5959
else // -- Prepare launch
6060
{
6161
// -- Rotate cannon to face the launch direction
62-
image_angle = lerp(image_angle, angle, 0.3);
62+
image_angle = lerp(image_angle, angle, 0.3*global.delta);
6363

6464
// -- Check if its looking near of the expected launch direction
6565
if (rotateTime > 320)

Platform82.gm82/objects/objControllerHUD.gml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ applies_to=self
1010
draw_set_font(debugFont)
1111
draw_text(view_xview[0] + 16, view_yview[0] + 16, string(fps))
1212
if (global.debug == -1) exit;
13-
draw_sprite_ext(sprCameraTrigger, 0, view_xview[0] + 248, view_yview[0] + 155, 179, 85, 0, c_black, 1);
14-
draw_text(view_xview[0] + 32, view_yview[0] + 32, string(global.idDelta));
13+
draw_sprite_ext(sprCameraTrigger, 0, view_xview[0] + 200, view_yview[0] + 155, 179+48, 85, 0, c_black, 1);
14+
draw_text(view_xview[0] + 32, view_yview[0] + 32, string(global.delta));
1515
draw_text(view_xview[0] + 32, view_yview[0] + 48, string(delta_time*1000));
1616
if (instance_exists(objPlayer))
1717
{
1818
draw_text(view_xview[0] + 318, view_yview[0] + 157, string(objPlayer.x))
1919
draw_text(view_xview[0] + 318, view_yview[0] + 167, string(objPlayer.y))
20-
draw_text(view_xview[0] + 248, view_yview[0] + 157, "XSPEED- " + string(objPlayer.xSpeed))
21-
draw_text(view_xview[0] + 248, view_yview[0] + 167, "YSPEED- " + string(objPlayer.ySpeed))
22-
draw_text(view_xview[0] + 248, view_yview[0] + 177, "GROUND- " + string(objPlayer.ground))
23-
draw_text(view_xview[0] + 248, view_yview[0] + 187, "DIR- " + string(objPlayer.xDir))
24-
draw_text(view_xview[0] + 248, view_yview[0] + 197, "ACTION- " + string(objPlayer.action))
25-
draw_text(view_xview[0] + 248, view_yview[0] + 217, "FPS- " + string(fps))
26-
draw_text(view_xview[0] + 248, view_yview[0] + 227, "ANIMATION- " + string(objPlayer.animIndex))
27-
draw_text(view_xview[0] + 338, view_yview[0] + 227, string(objPlayer.animFrame))
20+
draw_text(view_xview[0] + 200, view_yview[0] + 157, "XSPD- " + string(objPlayer.xSpeed) + " " + string(objPlayer.xVelocity))
21+
draw_text(view_xview[0] + 200, view_yview[0] + 167, "YSPD- " + string(objPlayer.ySpeed) + " " + string(objPlayer.yVelocity))
22+
draw_text(view_xview[0] + 200, view_yview[0] + 177, "GROUND- " + string(objPlayer.ground))
23+
draw_text(view_xview[0] + 200, view_yview[0] + 187, "DIR- " + string(objPlayer.xDir))
24+
draw_text(view_xview[0] + 200, view_yview[0] + 197, "ACTION- " + string(objPlayer.action))
25+
draw_text(view_xview[0] + 200, view_yview[0] + 217, "FPS- " + string(fps))
26+
draw_text(view_xview[0] + 200, view_yview[0] + 227, "ANIMATION- " + string(objPlayer.animIndex))
27+
draw_text(view_xview[0] + 298, view_yview[0] + 227, string(objPlayer.animFrame))
2828
if (mouse_check_button(mb_left))
2929
{
3030
objPlayer.x = lerp(objPlayer.x, mouse_x, 0.5);

Platform82.gm82/objects/objControllerRoom.gml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ applies_to=self
1515
*/
1616
/// -- Room control
1717

18-
global.idDelta = ((delta_time*1000)/1000000) / (1/60);
19-
global.roomTimer += 1 * global.idDelta;
18+
global.delta = ((delta_time*1000)/1000000) / (1/60);
19+
global.roomTimer += 1 * global.delta;
2020

2121
if (keyboard_check_pressed(ord("R")))
2222
{

Platform82.gm82/objects/objPlayer.gml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ applies_to=self
1111
// -- Speeds
1212
xSpeed = 0; // -- Horizontal speed (ground and air)
1313
ySpeed = 0; // -- Vertical speed (airborne)
14+
xVelocity = 0; // -- Horizontal speed (read only)
15+
yVelocity = 0; // -- Vertical speed (read only)
1416

1517
// -- Terrain
1618
slopeHeight = 0; // -- Slope height used while going up
@@ -20,6 +22,7 @@ applies_to=self
2022
solidPlace = 0;
2123
platformPlace = 0;
2224
platformID = 0; // -- ID of the meeting platform
25+
meetingWall = false;
2326

2427
// -- States
2528
action = actionNormal; // -- Current player state
@@ -90,7 +93,7 @@ applies_to=self
9093
!scrCollisionMain(x + xSpeed, y, collisionSolid) &&
9194
!scrCollisionMain(x + xSpeed, y + 1, collisionSolid))
9295
{
93-
x += xSpeed * global.idDelta;
96+
x += xSpeed * global.delta;
9497

9598
// -- Go down
9699
while (!(scrCollisionMain(x, y + 1, collisionSolid)))
@@ -104,6 +107,8 @@ applies_to=self
104107
var collisionMain;
105108
collisionMain = scrCollisionMain(x + xSpeed, y, collisionSolid);
106109

110+
meetingWall = false;
111+
107112
if (collisionMain)
108113
{
109114
slopeHeight = 0;
@@ -137,6 +142,7 @@ applies_to=self
137142
if (terrainCurrent != terrainPlatform)
138143
{
139144
xSpeed = 0;
145+
meetingWall = true;
140146
}
141147
}
142148
else // -- Otherwise, we are moving up a slope
@@ -146,7 +152,7 @@ applies_to=self
146152
}
147153

148154
// -- Approach to the xSpeed
149-
x += xSpeed * global.idDelta;
155+
x += xSpeed * global.delta;
150156
}
151157

152158
var collisionVertical, collisionLeave;
@@ -169,7 +175,7 @@ applies_to=self
169175
}
170176

171177
// -- Approach to the ySpeed
172-
y += ySpeed * global.idDelta;
178+
y += ySpeed * global.delta;
173179
/*"/*'/**//* YYD ACTION
174180
lib_id=1
175181
action_id=603
@@ -281,7 +287,7 @@ applies_to=self
281287
if (animFinished == false && animSpeed != 0)
282288
{
283289
// -- Change the frame depending on the animation speed
284-
animFrame += animSpeed*global.idDelta;
290+
animFrame += animSpeed*global.delta;
285291

286292
if (floor(animFrame) > animFrameEnd)
287293
{
@@ -310,15 +316,19 @@ applies_to=self
310316
if (place_meeting(x + xSpeed, y, physicalobj))
311317
{
312318
// -- Check if the object is touching a wall or another object
313-
if place_meeting(physicalobj.x - 24, physicalobj.y - 3, parTerrain) //&& scrPhysicsReturnDir(physicalobj) <= 0
319+
/*if place_meeting(physicalobj.x - 24, physicalobj.y - 3, parTerrain) //&& scrPhysicsReturnDir(physicalobj) <= 0
314320
|| place_meeting(physicalobj.x + 24, physicalobj.y - 3, parTerrain) //&& scrPhysicsReturnDir(physicalobj) == 1
315321
{
316322
exit;
317323
}
318324
else
319325
{
320-
physicalobj.xSpeed = (x - xprevious);
321-
physicalobj.image_angle += x - xprevious;
326+
x -= sign(physicalobj.x - x);
327+
//physicalobj.image_angle += x - xprevious;
328+
}*/
329+
if (physicalobj.meetingWall == true)
330+
{
331+
xSpeed = 0;
322332
}
323333
}
324334
/*"/*'/**//* YYD ACTION
@@ -337,6 +347,15 @@ applies_to=self
337347
instance_destroy();
338348
}
339349
}
350+
/*"/*'/**//* YYD ACTION
351+
lib_id=1
352+
action_id=603
353+
applies_to=self
354+
*/
355+
/// -- Velocity
356+
357+
xVelocity = (xprevious - x) / global.delta;
358+
yVelocity = (yprevious - y) / global.delta;
340359
#define Draw_0
341360
/*"/*'/**//* YYD ACTION
342361
lib_id=1

Platform82.gm82/objects/objTicketCollected.gml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,33 @@ applies_to=self
1515
*/
1616
/// -- Collected
1717

18-
collectedTimer = min(collectedTimer + 2, 90);
18+
collectedTimer = min(collectedTimer + 2 * global.delta, 90);
1919

2020
if (collectedTimer < 40)
2121
{
22-
x = lerp(x, objPlayer.x, 0.15);
22+
x = lerp(x, objPlayer.x, 0.15 * global.delta);
2323
y = scrEasings(collectedTimer, objPlayer.y, -40, 40, "easeOutBack");
2424
}
2525
else
2626
{
27-
x = lerp(x, objPlayer.x, 0.3);
28-
y = lerp(y, objPlayer.y, 0.15);
27+
x = lerp(x, objPlayer.x, 0.3 * global.delta);
28+
y = lerp(y, objPlayer.y, 0.15 * global.delta);
2929
}
3030

3131
if (collectedTimer >= 55)
3232
{
3333

3434
x = objPlayer.x;
3535
y = objPlayer.y;
36-
image_xscale = lerp(image_xscale, -dsin(collectedTimer*2)*4, 0.15)
36+
image_xscale = lerp(image_xscale, -dsin(collectedTimer*2)*4, 0.15 * global.delta)
3737
image_yscale = image_xscale
3838

39-
image_alpha -= 0.02;
39+
image_alpha -= 0.02 * global.delta;
4040
if (collectedTimer == 90)
4141
{
4242
repeat(3)
4343
{
44-
scrDummyCreate(choose(sprVFXSparkle1, sprVFXSparkle2), 0, x + irandom_range(20, -20), y + irandom_range(20, -20), 1, 1, irandom(360), 1, 0.4, 0, -2, bm_normal, c_white)
44+
scrDummyCreate(choose(sprVFXSparkle1, sprVFXSparkle2), 0, x + irandom_range(20, -20), y + irandom_range(20, -20), 1, 1, irandom(360), 1, 0.4 * global.delta, 0, -2, bm_normal, c_white)
4545
}
4646
instance_destroy();
4747
}

Platform82.gm82/objects/parPhysic.gml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ applies_to=self
2222
platformPlace = 0;
2323
platformID = 0; // -- ID of the meeting platform
2424

25+
meetingWall = false;
26+
2527
// -- Draw coordinates
2628
drawX = x;
2729
drawY = y;
@@ -42,7 +44,7 @@ applies_to=self
4244
!scrCollisionMain(x + xSpeed, y, collisionSolid) &&
4345
!scrCollisionMain(x + xSpeed, y + 1, collisionSolid))
4446
{
45-
x += xSpeed * global.idDelta;
47+
x += xSpeed * global.delta;
4648

4749
for (i = 0; i < spdFloor + 2; i += 1)
4850
{
@@ -89,15 +91,17 @@ applies_to=self
8991
x += sign(xSpeed);
9092
}
9193
xSpeed = 0;
94+
meetingWall = true;
9295
}
9396
else // -- Otherwise, we are moving up a slope
9497
{
9598
y -= slopeHeight;
99+
meetingWall = false;
96100
}
97101
}
98102

99103
// -- Approach to the xSpeed
100-
x += xSpeed;
104+
x += xSpeed * global.delta;
101105
}
102106

103107
if (ground == false)
@@ -123,7 +127,7 @@ applies_to=self
123127
}
124128

125129
// -- Approach to the ySpeed
126-
y += ySpeed;
130+
y += ySpeed * global.delta;
127131
/*"/*'/**//* YYD ACTION
128132
lib_id=1
129133
action_id=603
@@ -179,7 +183,7 @@ applies_to=self
179183
// -- Unclip from the object
180184
if (near != noone)
181185
{
182-
if ((place_meeting(bbox_left, y - 16, parTerrain) && scrPhysicsReturnDir(near) <= 0) || (place_meeting(bbox_right, y - 16, parTerrain) && scrPhysicsReturnDir(near) > 0))
186+
if ((place_meeting(x - 1, y - 16, parTerrain) && scrPhysicsReturnDir(near) <= 0) || (place_meeting(x + 1, y - 16, parTerrain) && scrPhysicsReturnDir(near) > 0))
183187
{
184188
// -- Don't push if the object is being pushed towards a wall
185189
exit;
@@ -191,6 +195,10 @@ applies_to=self
191195
y -= sign(near.y - y);
192196

193197
xSpeed -= sign(near.x - x);
198+
if (near.meetingWall == true)
199+
{
200+
xSpeed = 0;
201+
}
194202
}
195203
}
196204
/*"/*'/**//* YYD ACTION
@@ -249,7 +257,7 @@ applies_to=self
249257
// -- Loose speed
250258
xSpeed -= min(abs(xSpeed), 0.04) * sign(xSpeed);
251259

252-
image_angle += xSpeed*2;
260+
image_angle += xSpeed*2 * global.delta;
253261
#define Draw_0
254262
/*"/*'/**//* YYD ACTION
255263
lib_id=1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/// -- Stage init
1+
/// -- Stage init

Platform82.gm82/scripts/scrInit.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88

99
global.sfxVolume = 1;
1010
global.debug = -1;
11-
global.idDelta = 0;
11+
global.delta = 0;
1212

1313
room_goto_next();

Platform82.gm82/scripts/scrPlayerActionJump.gml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
case 0:
2020
// -- Apply gravity
21-
ySpeed = scrApproach(ySpeed, 11, phyGrv*global.idDelta);
21+
ySpeed = scrApproach(ySpeed, 11, phyGrv*global.delta);
2222
switch (sign(ySpeed))
2323
{
2424
case 1:
@@ -32,7 +32,7 @@
3232
if (input.inputAction == false)
3333
{
3434
// -- Cancel the jump
35-
ySpeed = -phyGrv*global.idDelta;
35+
ySpeed = -phyGrv*global.delta;
3636
}
3737
break;
3838
}

0 commit comments

Comments
 (0)