Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
[Tutorial] How to Jump
Author Message
Tony

Posted: 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.
Tony's programming blog. DWITE - a programming contest.

callawayguy24

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

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

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

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

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

Noone?
Tony

Posted: 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.
Tony's programming blog. DWITE - a programming contest.
thrivey

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

Posted: 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.
Tony's programming blog. DWITE - a programming contest.

thrivey

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

Posted: 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.
Tony's programming blog. DWITE - a programming contest.
thrivey

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

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

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

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

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

Any suggestions?
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 2 of 3  [ 43 Posts ]
Goto page Previous  1, 2, 3  Next
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: