Sorry, dass ich dazu nommel n Thread erstell.
Also, ich möchte, dass mein Spiel, egal bei welcher Framerate, gleich schnell läuft. Dass mach ich nun folgendermaßen:
Im Step:
global.fpss = "aktueller Roomspeed"/fps
Diese global.fpss multiplizier ich nun mit den ganzen Variablen (Speed etc.). Nun hab ich aber das Problem, dass mein Player (hab die FoxEngine), wenn ich z.B. den Speed von 60 auf 30 stell, höher springt als bei einem Wert bei 60. Hab schon alles mögliche probiert, hat aber nix gekplappt. Also her sind Events + Code:
Create:
Step:
Alles anzeigen
Press W-key:
So, das wären alle wichtigen Events. Kann mir echt nicht erklären, was daran falsch is.
Danke im Vorraus
Also, ich möchte, dass mein Spiel, egal bei welcher Framerate, gleich schnell läuft. Dass mach ich nun folgendermaßen:
Im Step:
global.fpss = "aktueller Roomspeed"/fps
Diese global.fpss multiplizier ich nun mit den ganzen Variablen (Speed etc.). Nun hab ich aber das Problem, dass mein Player (hab die FoxEngine), wenn ich z.B. den Speed von 60 auf 30 stell, höher springt als bei einem Wert bei 60. Hab schon alles mögliche probiert, hat aber nix gekplappt. Also her sind Events + Code:
Create:
Step:
GML-Quellcode
- p_maxspeed = global.fpss*5; //maximum speed
- p_accel = global.fpss*1; //move acceleration
- p_friction = global.fpss*0.5; //friction
- p_maxgravity = global.fpss*8; //maximum gravity speed
- p_jumpspeed = 30*global.fpss; //jump speed
- //perform friction on wspeed, it decreases the wspeed to 0
- wspeed = max(0,abs(wspeed)-p_friction)*sign(wspeed);
- //this is the magic code, first it checks if the player can move to the right,
- //if not, then it will start looping to see if it can go to right with a pixel up..
- for(i=0;i<abs(wspeed);i+=0.5) {
- var st, st2; st = place_free(x,y+2); st2 = sign(wspeed)/2;
- if(!st && place_free(x+st2*0.6,y+2)) { x+=st2*0.6; y+=2; }
- else if(!st && place_free(x+st2*0.8,y+1)) { x+=st2*0.8; y+=1; }
- else if(place_free(x+st2,y)) { x+=st2; }
- else if(!st && place_free(x+st2*0.8,y-1)) { x+=st2*0.8; y-=1; }
- else if(!st && place_free(x+st2*0.6,y-2)) { x+=st2*0.6; y-=2; }
- else if(!st && place_free(x+st2*0.4,y-3)) { x+=st2*0.4; y-=3; }
- else break;
- }
- //checks to see if the place below us is free
- if(place_free(x,y+1)) {
- //if the player is going up, and is not pressing up, then we want him to go down fast
- if(vspeed < 0 && !keyboard_check(ord('W'))) gravity = global.fpss*2.5;
- else gravity = global.fpss*1;
- }
- //no place free below the player! lets make him stop..
- else gravity=0;
- //we don't want the vspeed to go over 6
- if(vspeed > 6*global.fpss) vspeed=6*global.fpss
Press W-key:
GML-Quellcode
- //if there is ground below us, we want to jump! and ofcourse set the jump sprite
- if(!place_free(x,y+4)) {
- vspeed =- p_jumpspeed;
- if(sprite_index==spr_run_left||sprite_index==spr_idle_left) sprite_index=spr_jump_left;
- if(sprite_index==spr_run_right||sprite_index==spr_idle_right) sprite_index=spr_jump_right;
- }
So, das wären alle wichtigen Events. Kann mir echt nicht erklären, was daran falsch is.
Danke im Vorraus