Community
Message Board

Chat room - users
Game Over
( 394431 downloads)
Work In Progress
( 523201 downloads)
Links

Code Exchange
Downloads
Tutorials
Add to Favourites

Submit news

DIV ARENA FORUMS
Not logged in [Login - Register]
Go To Bottom

Printable Version  
Author: Subject: Day 5 - Jumping
MikeDX
DIV Nerd
*********


Avatar


Posts: 8388607
Registered: 25-2-2016
Member Is Offline


[*] posted on 4-3-2016 at 01:40 AM
Day 5 - Jumping


All the code and assets for this tutorial are on github !

On day 4, we added a little 3 frame running animation to our player. Now we're going to make him jump!

To catch up, download day 4 from github

Open up the DIV IDE. If you choose to continue at the splash screen, we should see where we were when we left off yesterday.





First thing we need to do is create our jumping sprite.

close all the open maps via the MAP menu, and make a copy of graph 1 like we did previously.

edit the new graph using the graph editor to show our character in a jump motion.



Once you're done, drag this image into your FPG and give it the ID of 5.







Now onto the jumping code!

Add these three new private variable in your player PROCESS PRIVATE
list just below animcount as follows:

Code:
jumping = FALSE; jump_offset = 0; jump_power = 8;





The "jumping" variable we will use to know if we are jumping (or not)
The "jump_offset" variable is going to be used to keep track of how many pixels to jump every "FRAME"
The "jump_power" variable is used to store how strongly our player can jump.

Let's see how these are used:

We will use the spacebar to jump, lets add the condition to check for space being pressed in our code:

Code:
IF ( KEY(_space) && jumping == FALSE ) jump_offset = -jump_power; jumping = TRUE; END


This code does two things. First it checks if the spacebar is pressed, and then checks to see if we are already jumping. If we are, we don't want to jump again! We'll later change this to also check if we are standing on the ground.

now below this, add another IF statement, to do some calculations on the Y variable.

Code:
IF ( jumping == TRUE ) y = y + jump_offset; jump_offset = jump_offset +1; graph = 5; IF ( jump_offset > jump_power ) jumping = FALSE; graph = 1; END END


This simplified jump routine changes the Y variable by a different ammount each frame and sets the graph to be 5 (which is our jump sprite), until the offset has return to its original value. At which point it set jumping back to FALSE, and returns the graph to the walking sprite.

Run the code with F10, we should get something that resembles some reasonable jumping animation




Keywords learned in this lesson:

Code:
TRUE FALSE IF() KEY() _space END graph y




That's all for this step. next time - running!
View user's profile View All Posts By User
humildadever
DIV Junior
**




Posts: 40
Registered: 27-2-2016
Member Is Offline


[*] posted on 14-3-2016 at 07:01 PM


I like Very good
View user's profile View All Posts By User
RKSoft
Game Making Machine!
******


Avatar


Posts: 232
Registered: 1-3-2016
Location: Germany
Member Is Offline


[*] posted on 15-3-2016 at 02:47 PM


looks good :)
View user's profile Visit user's homepage View All Posts By User
humildadever
DIV Junior
**




Posts: 40
Registered: 27-2-2016
Member Is Offline


[*] posted on 20-3-2016 at 12:50 AM


Thanks a lot. I waiting news upgrates..
View user's profile View All Posts By User
pommyman
DIV Junior
**




Posts: 10
Registered: 19-1-2017
Member Is Offline


[*] posted on 19-1-2017 at 10:29 AM


That's Brilliant!

I've got a little jumping man!
View user's profile View All Posts By User
RKSoft
Game Making Machine!
******


Avatar


Posts: 232
Registered: 1-3-2016
Location: Germany
Member Is Offline


[*] posted on 21-1-2017 at 04:21 PM


What about tutorial videos? Are they welcome?
View user's profile Visit user's homepage View All Posts By User
MikeDX
DIV Nerd
*********


Avatar


Posts: 8388607
Registered: 25-2-2016
Member Is Offline


[*] posted on 22-1-2017 at 05:09 PM


Absolutely! I have done some on YouTube already
View user's profile View All Posts By User
RKSoft
Game Making Machine!
******


Avatar


Posts: 232
Registered: 1-3-2016
Location: Germany
Member Is Offline


[*] posted on 23-1-2017 at 01:25 PM


Mike, i took your tutorial prg, played with your code and this is the current result :D

smb_tutorial_test1.jpg - 93kB smb_tutorial_test2.jpg - 87kB

But, i found some baaaaaad bugs. I report them in the bug report forum.

This is the current version. A work of 2 days (2-3 hours per day).

ESC to kill
Q or ALT+X to quit the program
Cursor keys to move, jump and duck.

[Edited on 23-1-2017 by RKSoft]

Attachment: Tutorial 1 - Jumpman.7z (14kB)
This file has been downloaded 2936 times

View user's profile Visit user's homepage View All Posts By User
MikeDX
DIV Nerd
*********


Avatar


Posts: 8388607
Registered: 25-2-2016
Member Is Offline


[*] posted on 23-1-2017 at 07:13 PM


wow that is really nice!

Kinda puts my tutorial to shame, you've take it to the next level and beyond!

on linux I had to rename screens.fpg to screens.FPG but apart from that it ran flawlessly
View user's profile View All Posts By User
RKSoft
Game Making Machine!
******


Avatar


Posts: 232
Registered: 1-3-2016
Location: Germany
Member Is Offline


[*] posted on 24-1-2017 at 02:43 PM


Thanks, but you are a better programmer, you work on DIV ;).
So, if i finish this little 1-level programm i will prepare it to a tilebase system with an editor (sperate) for DIV users who search such a system.
View user's profile Visit user's homepage View All Posts By User
MikeDX
DIV Nerd
*********


Avatar


Posts: 8388607
Registered: 25-2-2016
Member Is Offline


[*] posted on 24-1-2017 at 06:31 PM


I really like your colour scheme you have setup in the IDE. is that based on the blitz ide?
View user's profile View All Posts By User
RKSoft
Game Making Machine!
******


Avatar


Posts: 232
Registered: 1-3-2016
Location: Germany
Member Is Offline


[*] posted on 25-1-2017 at 02:59 PM


I think it could be like Blitz but in my Blitz ide i setup white background and black font color ^^. This (in my DIV) color scheme i like because it is good to read the syntax, numbers etcl. When you are interest i can write the definitions here. ;)
View user's profile Visit user's homepage View All Posts By User
dom cook
Div Pro
******




Posts: 387
Registered: 4-3-2016
Member Is Offline


[*] posted on 31-1-2017 at 10:10 PM
Mario of Many Colours.


Here's my effort.

It's Mario pretending to be Marvin Spectrum.

Keys: _up = jump
_right = roll
_down=slide
_z = red suit
_x = green suit
_c= blue suit
combinations of _z,_x,_c make the other colours.






Attachment: smb.fpg (33kB)
This file has been downloaded 2953 times

Attachment: smb.prg (7kB)
This file has been downloaded 2877 times SNAP0002.PNG - 4kB

Here's the music (courtesy of the amazing LMMS, which I've just discovered)
Attachment: forestrun.ogg (1.1MB)
This file has been downloaded 3239 times

[Edited on 1-2-2017 by dom cook]
View user's profile View All Posts By User
MikeDX
DIV Nerd
*********


Avatar


Posts: 8388607
Registered: 25-2-2016
Member Is Offline


[*] posted on 31-1-2017 at 11:17 PM


That's very cool Dom. I'm a huge fan of the spectrum. DIV can even output a spectrum type mode via a dll.


Roland, yes I'd like your colour config please! :)
View user's profile View All Posts By User
dom cook
Div Pro
******




Posts: 387
Registered: 4-3-2016
Member Is Offline


[*] posted on 1-2-2017 at 06:26 AM


Quote: Originally posted by MikeDX  
That's very cool Dom. I'm a huge fan of the spectrum. DIV can even output a spectrum type mode via a dll.


Not that Spetrum, Marvin Spetrum is/was a nice mini game involving hopping through coloured light gates. (It was on Newgrounds I think)
View user's profile View All Posts By User
MikeDX
DIV Nerd
*********


Avatar


Posts: 8388607
Registered: 25-2-2016
Member Is Offline


[*] posted on 1-2-2017 at 07:49 AM


Your colour scheme threw me off!

Still cool though
View user's profile View All Posts By User
RKSoft
Game Making Machine!
******


Avatar


Posts: 232
Registered: 1-3-2016
Location: Germany
Member Is Offline


[*] posted on 1-2-2017 at 05:19 PM


@dom cook
nice little programm, continue work and make it final :)
View user's profile Visit user's homepage View All Posts By User
dom cook
Div Pro
******




Posts: 387
Registered: 4-3-2016
Member Is Offline


[*] posted on 1-2-2017 at 07:26 PM


Quote: Originally posted by RKSoft  
@dom cook
nice little programm, continue work and make it final :)


Sure, just keep supplying the graphics. (Did you notice?)

Here's an update in which I've added music, removed a redundant key _right function, and changed the reverse scroll after collisions so that only the player is affected (wrt screen coordinates).



[Edited on 1-2-2017 by dom cook]

Attachment: smb.prg (7kB)
This file has been downloaded 2822 times

Attachment: forestrun.ogg (1.1MB)
This file has been downloaded 3204 times

View user's profile View All Posts By User
RKSoft
Game Making Machine!
******


Avatar


Posts: 232
Registered: 1-3-2016
Location: Germany
Member Is Offline


[*] posted on 1-2-2017 at 09:29 PM


It will be better when you pack all needed files into one zip ;)

Nice run, but i'm confused with the keys. ^^

[Edited on 1-2-2017 by RKSoft]
View user's profile Visit user's homepage View All Posts By User
willicab
DIV Junior
**


Avatar


Posts: 12
Registered: 12-7-2016
Member Is Offline


[*] posted on 2-2-2017 at 01:40 PM


Hi, can you give me permission to translate this tutorial and post it on my blog?



View user's profile View All Posts By User
MikeDX
DIV Nerd
*********


Avatar


Posts: 8388607
Registered: 25-2-2016
Member Is Offline


[*] posted on 2-2-2017 at 02:29 PM


Yes you can have permission to do that :)
View user's profile View All Posts By User
willicab
DIV Junior
**


Avatar


Posts: 12
Registered: 12-7-2016
Member Is Offline


[*] posted on 2-2-2017 at 02:44 PM


Oh thanks :D



View user's profile View All Posts By User

  Go To Top

Powered by XMB
XMB Forum Software © 2001-2012 The XMB Group
[Queries: 18]