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

Username:   Password: 
 RegisterRegister   
 [Tutorial] How to Jump
Index -> Programming, Turing -> Turing Tutorials
Goto page Previous  1, 2, 3  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Tony




PostPosted: Mon Jan 14, 2008 1:04 pm   Post subject: RE:[Tutorial] How to Jump

that's because you are skipping over the details

<= is not the same as =, try again.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
callawayguy24




PostPosted: Mon Jan 14, 2008 1:08 pm   Post subject: RE:[Tutorial] How to Jump

HE GOT IT, HE REALLY DID, thank you soo much Tony, u saved my carreer as a computer programer
thrivey




PostPosted: Mon Jan 14, 2008 1:08 pm   Post subject: Re: [Tutorial] How to Jump

Thanks a lot! It worked.. Really appreciate it.
thrivey




PostPosted: Mon Jan 14, 2008 3:43 pm   Post subject: Re: [Tutorial] How to Jump

I just got back from school and I just something, when I try to go under the platform it teleports me onto the platform. I made it so i'd be able to jump while on the platform though.
thrivey




PostPosted: Tue Jan 15, 2008 12:01 pm   Post subject: Re: [Tutorial] How to Jump

Noone? Razz
Tony




PostPosted: Tue Jan 15, 2008 12:13 pm   Post subject: RE:[Tutorial] How to Jump

That's because being under the platform is, well... being under the platform. Look over the code and see what if-conditions are met.

Hint: consider using <= POSITION_OF_PLATFORM with WIDTH_OF_PLATFORM for a more limited "snap back to the ground" check.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
thrivey




PostPosted: Tue Jan 15, 2008 12:40 pm   Post subject: Re: [Tutorial] How to Jump

if placey <= 250 and placex > 100 and placex < 200 and not placey > 250 then
placey := 250
speedy := 0
end if


I tried this but still the same. =/

To my understanding this means if placex is equal to both x 100-200 AND placey at 250 so basically it shouldn't do anything unless the co-ord of my character are (100,250), (101,250), (102,250) etc
Tony




PostPosted: Tue Jan 15, 2008 12:55 pm   Post subject: RE:[Tutorial] How to Jump

no, I already wrote in this thread
Tony @ Mon Jan 14, 2008 1:04 pm wrote:
that's because you are skipping over the details

<= is not the same as =, try again.


The very first thing in your code -- if placey <= 250

it's less than or equals to 250. Not "exactly 250".

btw, if you try to have it be exactly 250, there's a chance you'll fall in by a bit first (lets say get to 249) and then your character will fall through the ground).

Basically re-read the tutorial, all the necessary information is here.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
thrivey




PostPosted: Tue Jan 15, 2008 1:04 pm   Post subject: Re: [Tutorial] How to Jump

Put If i jump over it and falling down onto it it should eventually equal 250.
Tony




PostPosted: Tue Jan 15, 2008 1:29 pm   Post subject: RE:[Tutorial] How to Jump

only if your jump/fall speed is a constant 1 pixel per frame.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
thrivey




PostPosted: Tue Jan 15, 2008 4:26 pm   Post subject: Re: [Tutorial] How to Jump

My jump and fall speed are constants.

Edit: Want me to paste my whole code, and you can tell me wants wrong with it?
Gooie




PostPosted: Tue Jan 15, 2008 10:34 pm   Post subject: Re: RE:[Tutorial] How to Jump

Tony @ January 15th, 1:29 pm wrote:
only if your jump/fall speed is a constant 1 pixel per frame.


Actually, If you step through the application of the Y Velocity to the Y Position with a for loop, you can check every pixel, even if it isn't drawn there. That's what I used. It's super smooth, fast, and flexible.
Mazer




PostPosted: Tue Jan 15, 2008 10:52 pm   Post subject: RE:[Tutorial] How to Jump

Not to be a dick, but all of these platform questions are in the area of collision detection. I only wrote that "simple collision" part so that you could actually see how the jumping works. In anything even remotely interesting you would probably need to work out your own collision detection (or work in someone else's).

jnrdev (jump 'n' run)
Has some great tutorials for side scrolling games that may or may not help you.
thrivey




PostPosted: Wed Jan 16, 2008 12:46 pm   Post subject: Re: [Tutorial] How to Jump

I just can't get it... =/ This is what i got, if theres an easier way tell me, or if there is a way to fix it PLEASE tell me.

const ground := 50
const speed := 10
const jumpspeed := 23
const downforce := 2


var win := Window.Open ("graphics:800;600, offscreenonly")
var chars : array char of boolean

var placex, placey : int
var speedx, speedy : real

placex := 20
speedx := 0
placey := 400
speedy := 0

loop
Input.KeyDown (chars)
if chars ('x') then
exit
end if

%character movements.
if chars (KEY_LEFT_ARROW) then
speedx := -speed
if placey = ground then
end if
elsif chars (KEY_RIGHT_ARROW) then
speedx := speed
if placey = ground then
end if
else
speedx := 0
end if

% jumping off of group and platforms
if chars (KEY_UP_ARROW) and placey = ground then
speedy := jumpspeed
end if

if chars (KEY_UP_ARROW) and placey = 90 and placex > 100 and placex < 200 then
speedy := jumpspeed
end if

if chars (KEY_UP_ARROW) and placey = 340 then
speedy := jumpspeed
end if
% down force (gravity)
speedy -= downforce
placex += round (speedx)
placey += round (speedy)

%making sure the character doesn't go through the platforms floor, and walls.

if placey < ground then
placey := ground
speedy := 0
end if

if placey > 95 and placex < 100 and placex < 200 and placey < 85 then
placey := 90
speedy := 90
end if

if placey <= 340 and placex > 230 and placex < 400 then
placey := 340
speedy := 0
end if

if placex < 0 then
placex := 0
speedx := 0
end if

if placex > 770 then
placex := 770
speedx := 770
end if

%picture management(so the picture of the character never leaves)

if not placey = ground then
Pic.ScreenLoad ("mario4.jpg", placex - 2, placey + 2, 0)
end if


if chars (KEY_UP_ARROW) then
Pic.ScreenLoad ("mario4.jpg", placex - 2, placey + 2, 0)
end if

if not placey = ground and chars (KEY_LEFT_ARROW) then
Pic.ScreenLoad ("mario3.jpg", placex - 2, placey + 2, 0)
end if

if not placey = ground and chars (KEY_RIGHT_ARROW) then
Pic.ScreenLoad ("mario4.jpg", placex - 2, placey + 2, 0)
end if

if placey = ground and chars (KEY_LEFT_ARROW) then
Pic.ScreenLoad ("mario3.jpg", placex - 2, placey + 2, 0)
end if

if placey = ground and chars (KEY_RIGHT_ARROW) then
Pic.ScreenLoad ("mario4.jpg", placex - 2, placey + 2, 0)
end if

if placey = ground and not chars (KEY_LEFT_ARROW) then
Pic.ScreenLoad ("mario4.jpg", placex - 2, placey + 2, 0)
end if

%platforms and floor.

drawline (0, ground, maxx, ground, blue)
drawline (100, 90, 200, 90, 6)
drawline (230, 340, 400, 340, 6)
View.Update
delay (25)
cls
end loop
thrivey




PostPosted: Thu Jan 17, 2008 11:55 am   Post subject: Re: [Tutorial] How to Jump

Any suggestions?
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 3  [ 43 Posts ]
Goto page Previous  1, 2, 3  Next
Jump to:   


Style:  
Search: