Re: Jumping in bgt?

I'm not sure if this will help, but here we go:
if(key_pressed(KEY_SPACE) and me.z==0 and jumpstuntimer.elapsed>=jumpstuntime and jumping==false)
{
jumping=true;
p.play_stationary("sounds/jump.ogg",false);
}
if(jumping==true)
{
//I'm assuming your character is floating in the air. This is a problem. You're setting the variable to true, add in the z, then set it to false and continue floating. The condition doesn't trigger because the risetimer has just been restarted.
if(me.z<5 and risetimer.elapsed>=risetime)
{
risetimer.restart();
me.z+=1;
ascending=true;
}
if(me.z>=5 and ascending==true)
{
ascending=false;
}
if(me.z>1 and ascending==false and risetimer.elapsed>=risetime)
{
risetimer.restart();
me.z-=1;
}
if(me.z==1 and risetimer.elapsed>=risetime)
{
jumping=false;
p.play_stationary("sounds/land.ogg",false);
me.z=0;
}
}
//The movement code is simple. I like your function, but we can simplify it by checking if the player's coordinates are less or greater than the minimum or maximum of the field. I'll provide the fixed code, hopefully... Here goes the jump code
if(key_pressed(KEY_SPACE) and me.z==0 and jumpstuntimer.elapsed>=jumpstuntime and jumping==false)
{
jumping=true;
ascending=true;
p.play_stationary("sounds/jump.ogg",false);
}
if(jumping==true)
{
if(risetimer.elapsed>=risetime)
{
risetimer.restart();
if(ascending==true)
{
me.z++;
if(me.z>=5 and ascending==true)
{
ascending=false;
}
}
else
{
me.z-=1;
if(me.z==0)
{
jumping=false;
p.play_stationary("sounds/land.ogg",false);
me.z=0;
}
}
}
//I haven't ran this, simply because I kind of don't care for writing the class for a player in bgt, but hopefully this will work. I might have forgotten a brace, but try it out.
//Here's the movement code:
//Remove the if me.x<0 and the other three ifs at the beginning of your code chunk.
//Have a variable that checks if a player actually moved, and if so, play a sound. I won't write that part, I'm sure you can handle it.
bool move(int dir)
{
movetimer.restart();
if(dir==1 and me.y<max)
{
me.y++;
return true;
}
else if(dir==2 and me.x<maxx)
{
me.x++;
return true;
}
else if(dir==3 and me.y>0)
{
me.y-=1;
return true;
}
else if(dir==4 and me.x<0)
{
me.x-=1;
return true;
}
return false;
}

Code aside, this is a problem, Redfox. You need to learn how to debug your code. I'm not gonna be there to sit down and give you ideas as to where and how you screwed up. More over, if I do so, I may not always provide solutions to your issue. If you can't debug something you're making, step down. Build a simpler project. I'm not criticizing you, I'm just giving you some advice. You'll thank me later, trust me.



-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : ogomez92 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : redfox via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : redfox via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : redfox via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : redfox via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : redfox via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : jack via Audiogames-reflector

Reply via email to