Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Jumping Over a Wall
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
SAMZ




PostPosted: 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
Sponsor
sponsor
Tony




PostPosted: 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
SAMZ




PostPosted: 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




PostPosted: Wed May 21, 2008 11:07 am   Post subject: RE:Jumping Over a Wall

I think my reply still stands.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
SAMZ




PostPosted: 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




PostPosted: 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?
code:

posx := posx
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
SAMZ




PostPosted: 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 Hit Wall

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




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
SAMZ




PostPosted: 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




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: