DIV ARENA FORUMS

RKSoft Tutorial - Jump and Run with hardmap

RKSoft - 6-2-2017 at 04:27 PM

So, here is my little tutorial for you if you want to make a plattform game like Super Mario. The game contains 2 enemies and a playable level to show how it works.

The features are:
- one playable level with a hardmap (see screens.fpg)
- 2 enemies, you can jump on their head to kill them
- animated blocks and coins
- a final with animation
- a basic title screen
- controls are cursor keys for moving and jumping and left shift to run

The code has some remarks for your information. Take a look into the player process how it works with the collision (to hardmap), jumping, running etc. I hope it helps somebody to making games like this. If you have questions, i will answer all!

Permissions to use this code is free for all and no needs to copyright to me! But it will be nice when you will do. The copyright of the player graphic is by me and you are not allowed to use them without my permission! The tileset (graphic blocks) are copyright by Black Squirrel from Mario Fan Game Galaxy!

Allowed are:
Use this code if you want and make changes. The font is by me and for free to use.

Attachment: Tutorial 1 - jumpman.zip (587kB)
This file has been downloaded 1729 times

tut1-jumpman1.jpg - 84kB tut1-jumpman2.jpg - 81kB tut1-jumpman3.jpg - 79kB tut1-jumpman4.jpg - 72kB

MikeDX - 6-2-2017 at 04:57 PM

This is beautiful. Thanks Roland!

RKSoft - 6-2-2017 at 10:06 PM

Next tutorial will be the same but with tiles and not with hardmap. And, a simple level editor for it. I think it will help more people.

willicab - 9-2-2017 at 05:49 PM

Excellent work!!

dom cook - 13-2-2017 at 05:05 PM

Looking good. Are you going to make a game or just some Tutorials?

RKSoft - 29-4-2017 at 10:11 PM

Currently, only tutorials because there is a memory bug in compiled exe for Windows. Maybe, after a fix i remake some little Atari 2600 games with better graphics. For currently projects, you can take a look on my homepage at https://rksoft.info . I made some mock-ups for the Commodore Plus/4 homecomputer. ^^

[Edited on 29-4-2017 by RKSoft]

CicTec - 5-5-2017 at 11:06 AM

Hello RKSoft,

After removing all "hacks" to test your tutorial I noticed some logic errors in the instruction calls, I have corrected the PRG for it to work according to the DIV execution logic, I did not encounter any problems running with the new version, you can confirm this when the new build comes out.

Today I have finished the code re-format, I will try to correct the memory leak bug in the release version, so that the new build can be released, another little of a patience.

Meanwhile your correct tutorial:


Attachment: jumpman.prg (32kB)
This file has been downloaded 1598 times


RKSoft - 5-5-2017 at 06:01 PM

Thx!!! :)

What did you changed in my code? I saw you remarked the variable "programm_continue" in that code. Is this all? oO If yes, well done and great work when this run without problems.

CicTec - 5-5-2017 at 07:45 PM

:)

I have changed "setup_level" process from:
Code:
process setup_level(stage) private temp; begin switch (stage) case 1: gfx_background = 100; gfx_hardmap = 300; gfx_screen = 200; start_scroll(0, file_screen, gfx_screen, gfx_background, 0, 4); get_point(file_screen, gfx_screen, 1, &x, &y); player(x, y); /* Player */ scroll[0].x0 = x - 160; scroll[0].y0 = 0; scroll[0].x1 = scroll[0].x0; scroll[0].y1 = 0; /*----------------------------------------*/ from temp = 2 to 16; get_point(file_screen, gfx_screen, temp, &x, &y); goomba(x, y); end /* Goomba */ get_point(file_screen, gfx_screen, 17, &x, &y); koopa(x, y); /* Koopa */ from temp = 18 to 30; get_point(file_screen, gfx_screen, temp, &x, &y); block_coin(x, y, 0); end /* Block: Coin */ get_point(file_screen, gfx_screen, 31, &x, &y); block_crash(x, y, 2); /* Block: Crashable */ get_point(file_screen, gfx_screen, 32, &x, &y); block_crash(x, y, 2); /* Block: Crashable */ from temp = 33 to 57; get_point(file_screen, gfx_screen, temp, &x, &y); coin(x, y); end /* Coin */ get_point(file_screen, gfx_screen, 59, &x, &y); goomba(x, y); /* Goomba */ from temp = 60 to 87; get_point(file_screen, gfx_screen, temp, &x, &y); block_crash(x, y, 0); end /* Block: Crashable */ get_point(file_screen, gfx_screen, 58, &x, &y); final(x, y); /* Final */ from temp = 88 to 94; get_point(file_screen, gfx_screen, temp, &x, &y); water(x, y); end /* Water */ end default: gfx_background = 100; gfx_hardmap = 300; gfx_screen = 200; start_scroll(0, file_screen, gfx_screen, gfx_background, 0, 4); title(); /* Titlescreen */ scroll[0].x0 = 0; scroll[0].y0 = 0; scroll[0].x1 = 0; scroll[0].y1 = 0; /*----------------------------------------*/ from temp = 2 to 16; get_point(file_screen, gfx_screen, temp, &x, &y); goomba(x, y); end /* Goomba */ get_point(file_screen, gfx_screen, 17, &x, &y); koopa(x, y); /* Koopa */ from temp = 18 to 30; get_point(file_screen, gfx_screen, temp, &x, &y); block_coin(x, y, 0); end /* Block: Coin */ get_point(file_screen, gfx_screen, 31, &x, &y); block_crash(x, y, 2); /* Block: Crashable */ get_point(file_screen, gfx_screen, 32, &x, &y); block_crash(x, y, 2); /* Block: Crashable */ from temp = 33 to 57; get_point(file_screen, gfx_screen, temp, &x, &y); coin(x, y); end /* Coin */ get_point(file_screen, gfx_screen, 59, &x, &y); goomba(x, y); /* Goomba */ from temp = 60 to 87; get_point(file_screen, gfx_screen, temp, &x, &y); block_crash(x, y, 0); end /* Block: Crashable */ get_point(file_screen, gfx_screen, 58, &x, &y); final(x, y); /* Final */ from temp = 88 to 94; get_point(file_screen, gfx_screen, temp, &x, &y); water(x, y); end /* Water */ end end stageSizeX = graphic_info(file_screen, gfx_screen, g_wide); stageSizeY = graphic_info(file_screen, gfx_screen, g_height); player_time = 399; game = true; // program_continue = true; end


to:
Code:
process setup_level(stage) private temp; begin player_time = 399; game = true; switch (stage) case 1: gfx_background = 100; gfx_hardmap = 300; gfx_screen = 200; start_scroll(0, file_screen, gfx_screen, gfx_background, 0, 4); get_point(file_screen, gfx_screen, 1, &x, &y); player(x, y); /* Player */ scroll[0].x0 = x - 160; scroll[0].y0 = 0; scroll[0].x1 = scroll[0].x0; scroll[0].y1 = 0; /*----------------------------------------*/ from temp = 2 to 16; get_point(file_screen, gfx_screen, temp, &x, &y); goomba(x, y); end /* Goomba */ get_point(file_screen, gfx_screen, 17, &x, &y); koopa(x, y); /* Koopa */ from temp = 18 to 30; get_point(file_screen, gfx_screen, temp, &x, &y); block_coin(x, y, 0); end /* Block: Coin */ get_point(file_screen, gfx_screen, 31, &x, &y); block_crash(x, y, 2); /* Block: Crashable */ get_point(file_screen, gfx_screen, 32, &x, &y); block_crash(x, y, 2); /* Block: Crashable */ from temp = 33 to 57; get_point(file_screen, gfx_screen, temp, &x, &y); coin(x, y); end /* Coin */ get_point(file_screen, gfx_screen, 59, &x, &y); goomba(x, y); /* Goomba */ from temp = 60 to 87; get_point(file_screen, gfx_screen, temp, &x, &y); block_crash(x, y, 0); end /* Block: Crashable */ get_point(file_screen, gfx_screen, 58, &x, &y); final(x, y); /* Final */ from temp = 88 to 94; get_point(file_screen, gfx_screen, temp, &x, &y); water(x, y); end /* Water */ end default: gfx_background = 100; gfx_hardmap = 300; gfx_screen = 200; start_scroll(0, file_screen, gfx_screen, gfx_background, 0, 4); stageSizeX = graphic_info(file_screen, gfx_screen, g_wide); stageSizeY = graphic_info(file_screen, gfx_screen, g_height); title(); /* Titlescreen */ scroll[0].x0 = 0; scroll[0].y0 = 0; scroll[0].x1 = 0; scroll[0].y1 = 0; /*----------------------------------------*/ from temp = 2 to 16; get_point(file_screen, gfx_screen, temp, &x, &y); goomba(x, y); end /* Goomba */ get_point(file_screen, gfx_screen, 17, &x, &y); koopa(x, y); /* Koopa */ from temp = 18 to 30; get_point(file_screen, gfx_screen, temp, &x, &y); block_coin(x, y, 0); end /* Block: Coin */ get_point(file_screen, gfx_screen, 31, &x, &y); block_crash(x, y, 2); /* Block: Crashable */ get_point(file_screen, gfx_screen, 32, &x, &y); block_crash(x, y, 2); /* Block: Crashable */ from temp = 33 to 57; get_point(file_screen, gfx_screen, temp, &x, &y); coin(x, y); end /* Coin */ get_point(file_screen, gfx_screen, 59, &x, &y); goomba(x, y); /* Goomba */ from temp = 60 to 87; get_point(file_screen, gfx_screen, temp, &x, &y); block_crash(x, y, 0); end /* Block: Crashable */ get_point(file_screen, gfx_screen, 58, &x, &y); final(x, y); /* Final */ from temp = 88 to 94; get_point(file_screen, gfx_screen, temp, &x, &y); water(x, y); end /* Water */ end end // program_continue = true; end


This is because when process instances are created, they are executed immediately, in the case of the "goomba" and "koopa" processes, the "if (not game) return; end" statement, and since "game" Is not yet set to TRUE, processes are destroyed instantly.
Also, the "title" process needs variables like "stageSizeX" that were initialized after creation, now everything is set before.

Beyond this small change the instructions of "hack" have been commented on.

RKSoft - 6-5-2017 at 01:27 PM

dang, my fail. I use graphic_info() in player process, not good. The stageSizeX and stageSizeY should do their work not only in the default SWITCH ;). I rework the code again when you release the next nightly build (or next official build?) and release it here...

But this cannot be the failure.
With your rework of DIV code i can remove the "hack" (ie: programm_continue etc.) completely?

Where was the bug in the DIV code?

[Edited on 6-5-2017 by RKSoft]

CicTec - 6-5-2017 at 03:18 PM

Quote: Originally posted by RKSoft  
dang, my fail. I use graphic_info() in player process, not good. The stageSizeX and stageSizeY should do their work not only in the default SWITCH ;). I rework the code again when you release the next nightly build (or next official build?) and release it here...

As you prefer :)

I think it's a nightly build, or maybe a new beta, this will see Mike when the new source code is over.

Quote: Originally posted by RKSoft  

But this cannot be the failure.
With your rework of DIV code i can remove the "hack" (ie: programm_continue etc.) completely?

For what I have tested, yes, you can remove it completely, however, wait for the new build to test it, so to confirm it's ok.

Quote: Originally posted by RKSoft  

Where was the bug in the DIV code?

[Edited on 6-5-2017 by RKSoft]

Hard to know the exact point, I had to make some changes to the original code to avoid conflicts with modern compilers, data type mismatching etc..., have also been corrected many inside bugs of memory lieaks.