Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
26 May, 2013, 03:11:43 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1]   Go Down
  Print  
Author Topic: Jump code help please -  (Read 336 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
stevon8ter
LV7 Elite (Next: 700)
*******
Offline Offline

Gender: Male
Last Login: 14 May, 2013, 20:28:46
Date Registered: 22 March, 2012, 18:23:00
Location: In my house :o Belgium
Posts: 629


Topic starter
Total Post Ratings: +10

View Profile
« on: 27 July, 2012, 03:39:04 »
0

Ok, i don't know yet what game i'm gonna make and don't have my 84+ with me atm, so don't blame me if i make misstakes xD

If i would have

:horizontal 0
:47->x
:61->y
:pxl-on(61,50
:lbl 1
:pxl-on(y,x
:x->a
:y->b
:delvar k
:while k /= 24 and k /= 26 and k /= 21
:getkey-> k
:x+(k=26)-(k=24)->x
:jump code
:end
:pxl-off(b,a
:goto 1

Ok, i know it's not optimized and that the goto's aren't good, and i know collision detect isn't here as well

But how could i insert a jump code here? ( other movement can be tolorated xd just put the movement+jump here, i know how to do the jump and i get the gravity a bit but i keep having troubles with the falling-on-platform-thing-and-not-falling-trough-it ) Tongue
Logged

None of my posts are meant offending... I you feel hurt by one of my posts, tell me ... So i can appoligise me and/or explain why i posted it


Hi there, I'm the allmighty (read as: stupid, weak...) STEVON8TER
dinosteven
LV4 Regular (Next: 200)
****
Offline Offline

Gender: Male
Last Login: Today at 01:57:23
Date Registered: 20 July, 2012, 02:00:22
Location: Within this text.
Posts: 158


Total Post Ratings: +7

View Profile
« Reply #1 on: 27 July, 2012, 08:33:36 »
0


1
2
3
:If not(pxl-test(Y+2,X)
:Y+1->Y  // or whatever you want to do for gravity
You should also use this to check if they should be able to jump or not:

1
2
3
:If (K=21)pxl-test(Y+2,X
:5->J // something that starts the jump
Logged
stevon8ter
LV7 Elite (Next: 700)
*******
Offline Offline

Gender: Male
Last Login: 14 May, 2013, 20:28:46
Date Registered: 22 March, 2012, 18:23:00
Location: In my house :o Belgium
Posts: 629


Topic starter
Total Post Ratings: +10

View Profile
« Reply #2 on: 27 July, 2012, 09:35:00 »
0

Ok, thx, i'll try it out, but not now, tonight i think xD
Logged

None of my posts are meant offending... I you feel hurt by one of my posts, tell me ... So i can appoligise me and/or explain why i posted it


Hi there, I'm the allmighty (read as: stupid, weak...) STEVON8TER
dinosteven
LV4 Regular (Next: 200)
****
Offline Offline

Gender: Male
Last Login: Today at 01:57:23
Date Registered: 20 July, 2012, 02:00:22
Location: Within this text.
Posts: 158


Total Post Ratings: +7

View Profile
« Reply #3 on: 27 July, 2012, 16:43:00 »
0

Also, I suggest that you make your jumping by 1 unit at a time. When I made a jump game, what I did for jumping was adding the 'force' upward to the position, and lowering the 'force' upward according to gravity, until it was on top of a block. Ex:

1
2
3
:Y-C->Y
:If not(pxl-test(Y+2,X
:C-1->C
Unfortunately, that means that it sometimes skips a few pixels and falls through the block... I failed and gave up on it, but now I realize that instead of doing that, you can do this:

1
2
3
4
:Y-(C>0)->Y
:Y+(C<0)->Y
:If not(pxl-test(Y+2,X
:C-1->C
The (C>0) will always be 1 until C is 0 or lower, and it will go up by 1 every time. The (C<0) will always be 1 when C is 0 or lower, and it will go down every time. Smiley
Logged
stevon8ter
LV7 Elite (Next: 700)
*******
Offline Offline

Gender: Male
Last Login: 14 May, 2013, 20:28:46
Date Registered: 22 March, 2012, 18:23:00
Location: In my house :o Belgium
Posts: 629


Topic starter
Total Post Ratings: +10

View Profile
« Reply #4 on: 27 July, 2012, 17:04:23 »
0

Euhm, could you maybe set it in a little example? Like prog start, clrdraw, then a little map, the pixel that moves, and then movement and jump? Or is it to much?

Ps: if you'dd do that, please in code like here, i can't transfer progs atm
Logged

None of my posts are meant offending... I you feel hurt by one of my posts, tell me ... So i can appoligise me and/or explain why i posted it


Hi there, I'm the allmighty (read as: stupid, weak...) STEVON8TER
dinosteven
LV4 Regular (Next: 200)
****
Offline Offline

Gender: Male
Last Login: Today at 01:57:23
Date Registered: 20 July, 2012, 02:00:22
Location: Within this text.
Posts: 158


Total Post Ratings: +7

View Profile
« Reply #5 on: 27 July, 2012, 17:27:12 »
0

I'm just going to write this from memory, 'cause my calc's backing up and I gotta go soon.
Spoiler for Hidden:
:47->X:31->Y:0->C
:ClrDraw
:Draw some stuff for it to drop on
:Repeat Y>54
:pxl-on(Y,X
:getKey->K
:If K=21 and pxl-test(Y+2,X
:9->C
:If not(pxl-test(Y+2,X
:C-1->C
:If pxl-test(Y+2,X
:0->C
:pxl-off(Y,X
:X+(K=26)-(K=24->X
:Y-(C>0)->Y
:Y+(C<0)->Y
:End
That's pretty rough, I wrote it in like 5 minutes. Let me know how it works for you.
EDIT: You should probably store pxl-test(Y+2,X) to a variable, cause it is used a bunch of times.
« Last Edit: 27 July, 2012, 17:29:28 by dinosteven » Logged
stevon8ter
LV7 Elite (Next: 700)
*******
Offline Offline

Gender: Male
Last Login: 14 May, 2013, 20:28:46
Date Registered: 22 March, 2012, 18:23:00
Location: In my house :o Belgium
Posts: 629


Topic starter
Total Post Ratings: +10

View Profile
« Reply #6 on: 27 July, 2012, 18:00:24 »
0

Ok, i'll try it later on today, thanks anyway
Logged

None of my posts are meant offending... I you feel hurt by one of my posts, tell me ... So i can appoligise me and/or explain why i posted it


Hi there, I'm the allmighty (read as: stupid, weak...) STEVON8TER
Hayleia
Programming Absol
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Last Login: Yesterday at 19:30:26
Date Registered: 01 June, 2011, 20:12:47
Location: ud-ud ?
Posts: 2057


Total Post Ratings: +256

View Profile
« Reply #7 on: 27 July, 2012, 19:36:06 »
0

EDIT: You should probably store pxl-test(Y+2,X) to a variable, cause it is used a bunch of times.
Or use some "Then", "End" and "Else" Wink

:47->X:31->Y:0->C
:ClrDraw
:Draw some stuff for it to drop on
:Repeat Y>54
:pxl-on(Y,X
:getKey->K
:If pxl-test(Y+2,X
:Then
  :0->C
  :If K=21:9->C
:Else
  :C-1->C
:End
:pxl-off(Y,X
:X+(K=26)-(K=24->X
:Y-(C>0)->Y
:Y+(C<0)->Y
:End

Moreover, you made something strange here:
  :If K=21 and pxl-test(Y+2,X
  :9->C
  ...
  :If pxl-test(Y+2,X
  :0->C
So the first If is useless Huh?
« Last Edit: 27 July, 2012, 19:38:11 by Hayleia » Logged





Spoiler for what I am according to...:
me: useless
Pokemon Test: an Absol
turiqwalrus: an eggplant
p2: A HUMAN BEING !
Blackpilar and p2: iplantonlyplantwantplanttoplantknowplantifplantyouplantareplantaplantboyplantorplantaplantgirlplant
click here to know where you got your last +1s
stevon8ter
LV7 Elite (Next: 700)
*******
Offline Offline

Gender: Male
Last Login: 14 May, 2013, 20:28:46
Date Registered: 22 March, 2012, 18:23:00
Location: In my house :o Belgium
Posts: 629


Topic starter
Total Post Ratings: +10

View Profile
« Reply #8 on: 27 July, 2012, 23:13:24 »
0

Indeed, i guess it could be solved by swithing the places of those 2 if-statements
Logged

None of my posts are meant offending... I you feel hurt by one of my posts, tell me ... So i can appoligise me and/or explain why i posted it


Hi there, I'm the allmighty (read as: stupid, weak...) STEVON8TER
dinosteven
LV4 Regular (Next: 200)
****
Offline Offline

Gender: Male
Last Login: Today at 01:57:23
Date Registered: 20 July, 2012, 02:00:22
Location: Within this text.
Posts: 158


Total Post Ratings: +7

View Profile
« Reply #9 on: 28 July, 2012, 06:19:29 »
0

Oops, my mistake!

1
2
3
:If pxl-test(Y+2,X
:0->C
Should be

1
2
3
:If pxl-test(Y+2,X) and (C<0)
:0->C
It was meant to stop the falling, so that gravity doesn't take effect upon landing.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.204 seconds with 30 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.