I Wanna Be The Forums!

Please login or register.

Login with username, password and session length
Advanced search  

News:

Chat button has been eaten. Click here to join in the idling fun!

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Einstein1896

Pages: [1]
1
Announcements! / Re: Fix My Game: IWBTG Source Code Release
« on: March 17, 2012, 09:09:57 pm »
Sorry -- I didn't mean to imply that!
I just meant, some clever coding can ensure consistency...

(I like your avatar, btw)

on the original thread topic... I feel like it might be easier and better to just rewrite the whole game from scratch in C++ or Java or something, because (no offense) Kayin's code is a nightmare.

2
Announcements! / Re: Fix My Game: IWBTG Source Code Release
« on: March 16, 2012, 08:54:48 pm »
There's a very good reason why one would use delta time: the game can be slowed down or sped up dynamically. (E.G, bullet time fighting!)
Also, you can completely avoid the jump height problem with calculus or kinematics: just add 1/2 * g * t^2 to the y position every update, where g is the gravity and t is the delta time.
full pseudocode:

let dy = yspd*t + .5*g*t*t;//dy is the change in y this update, yspd is the current vertical velocity (positive or negative) in units per second, g is the acceleration y-component in units per second per second, and t is the delta time in seconds.
yspd += g*t;
for (int i=0;i<dy;i++)
{
    if (no obstacle one pixel below)
        y++;
    else
        yspd=0;
}


of course, you'd also check if there was something below you /before/ you accelerated in the first place.
If it's not a pixel-based game, still use the same dy code, but instead of iterating through every pixel of vertical movement, iterate through all the obstacles, find the highest one that intercepts your path (from the starting y position to y + dy), and set your y position to be that objects y position (minus how tall you are)
theoretically, this will work perfectly and consistently with any amount of lag, though it gets more complicated with horizontal speed; rather than plotting a linear path, the path has to be a parabola.

Furthermore, the problems with this being hindering to user input under laggy conditions can be fixed by inserting fake slow-down under heavy lag.

Pages: [1]