•      Sign In
• Create Account

codingnoobie

Member Since 02 Sep 2012
Offline Last Active Sep 10 2012 09:37 PM

In Topic: Player Acceleration

10 September 2012 - 01:35 PM

@Bacterius
I think so.

What you are saying is *time isn't necessary because it's already there as it's updated every set interval, right?

I tested it out, and I'm happy to see it working.

@BeerNutts
I wanted to use float but I didn't know how big is 1f in comparison to 1 pixel so, I used integers and doubles, for now. :-P

I plugged this in as gravity:

double gravity=980/360; (converting at 1m=100pixels, and 60 delta = second)

I made the heroYspeed decrease in value when key.space is inputted, so that he jumps with deceleration and falls with acceleration.

I want to tweak the values around a bit, but I think I will move on to horizontal movement and friction. Khan academy, maybe?

In Topic: Player Acceleration

10 September 2012 - 01:05 AM

I looked into it, messed around with delta again, and I set the fps to 60 and I could finally got it working, kind of.

Below is the code that I got working.

public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException{
// unit = ms?
counter += delta;

heroYspeed+=gravity*counter;
heroY+=heroYspeed;

if (heroY>=440){
counter=0;
heroYspeed=0;

Input input= gc.getInput();
if(input.isKeyDown(Input.KEY_UP)){
heroY=0;
}

}

I know I didn't use heroY += heroYspeed * time; but the character disappears when I use that code. It made sense that velocity * time would be distance and I wanted it to work, but I'm tired from wrapping my head around a few concepts, ha, ha.... (I spend some time in khan academy, and exercising my brain )

I also want to find out about the relationship between delta, fps and update time. It's vague to me right now.

PARTNERS