Author |
Message |
SAMZ
|
Posted: Tue May 20, 2008 9:52 am Post subject: Jumping Over a Wall |
|
|
I am doing a high jump game but I am having trouble jumping over a wall and landing on a mat using my character. The wall works but as I jump over it, as soon as I reach the height of the wall on the other side, I go back to where I jumped at the wall.
Quote: if posx <= WALL and posy < 300 then
posx:= WALL + 10
posx := posx
velx := 0
end if
How can I jump over the wall and land on the mat. 300 is the height of the Wall. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Tue May 20, 2008 11:27 am Post subject: RE:Jumping Over a Wall |
|
|
take note of the position (on the other side) where this happens, and see if your condition statement
code: |
if posx <= WALL and posy < 300 then
|
holds true for that set of posx/posy |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
SAMZ
|
Posted: Wed May 21, 2008 8:03 am Post subject: Re: Jumping Over a Wall |
|
|
I see where I went wrong there. But now I still can't jump over the wall. I am still confused. Any more insight?
Quote:
if posx >= WALL and posy < 300 then
posx:= WALL + 10
posx := posx
velx := 0
end if |
|
|
|
|
|
Tony
|
|
|
|
|
SAMZ
|
Posted: Wed May 21, 2008 11:27 am Post subject: Re: RE:Jumping Over a Wall |
|
|
Tony @ Wed May 21, 2008 11:07 am wrote: I think my reply still stands.
No, it does not hold true. Do I put an elsif statement or add a not statement? |
|
|
|
|
|
Tony
|
Posted: Wed May 21, 2008 12:34 pm Post subject: RE:Jumping Over a Wall |
|
|
That depends on what you want your condition to be. How does the problem manifest itself now?
Also, what does this line of code do?
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
SAMZ
|
Posted: Thu May 22, 2008 5:11 pm Post subject: Re: Jumping Over a Wall |
|
|
Honestly, I don't know. I think I wrote it while not pay attention
I want my condition to be
1. Have the Wall (the line) stop the person.
2. Be able to fall below the height of the line on the other side of the wall.
My "mat" where the user hits to win, is at a height of 130 and the wall height is 300.
The problem is my first if statement makes it the wall height of 300 applies to the other side of the wall. |
|
|
|
|
|
Tony
|
Posted: Thu May 22, 2008 5:36 pm Post subject: RE:Jumping Over a Wall |
|
|
So then you need to have a more specific IF statement -- that that also specifies the side of the wall as a part of the conditions. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Sponsor Sponsor
|
|
|
SAMZ
|
Posted: Fri May 23, 2008 8:00 am Post subject: Re: Jumping Over a Wall |
|
|
Okay, I understand what you mean. I made variables for the right side and the left side of the wall. Here's my code. Thanks for the help. I appreciate it.
if posx < WALLR and posy < 300 then
posx := WALLR + 10
velx := 0
elsif posx > WALLL and posy > 300 then
velx := 0
end if
It still doing where it teleports me back. |
|
|
|
|
|
SAMZ
|
Posted: Mon Jun 02, 2008 9:29 am Post subject: Re: Jumping Over a Wall |
|
|
Any help? Im really struggling. I even looked at the Jumping Tutorial. |
|
|
|
|
|
|