Work in Progress

Platformer (WIP)

3

defcon_zero 2020-03-06 20:11 (Edited)

My first attempt at anything involving collision. Not working too well, and I can't seem to figure it out. I've looked at tons of topics and games, and managed to scrape this together. I also want to add gravity, and figure out how to add multiple levels. Also I was thinking that the visual style could change from level to level with certain themes. Collision and gravity are my main problems right now though.


v1.1 + added a door (currently doesn't do anything, and is in the foreground instead of background)

v2 + working collision and gravity! (thanks was8bit and Timo). Also I changed the layout to a more rage-inducing one. It should be possible, but gave up on testing it, haha..

v2.01 + After further testing, I realized that part of it actually was impossible.....oops. Lol, anyways, that's fixed now :)

v3 + completely re-did lvl 1, and added 2 more levels! (thanks again to was8bit for all the help!) Also will probably change up these level designs in the future, as well as add even more levels.

platformer v2.01.nx | Open in app
2020-03-09 00:13
platformer v2.nx | Open in app
2020-03-08 23:24

was8bit 2020-03-08 16:24

Here is my "go to" source for help...

https://lowresnx.inutilis.com/topic.php?id=318

Attached is fixed code using TIMO's subs ;)



platformer Fixed.nx | Open in app
2020-03-08 16:24

defcon_zero 2020-03-08 23:24

Thanks, this really helped me out. Although I can't currently wrap my head around how this works, I tweaked it and just released a new version that actually works. :)


was8bit 2020-03-08 23:29

Glad to help..

Timo’s code always checks all 4 corners of the sprite each time... to see if any corner will hit any occupied cell...


was8bit 2020-03-08 23:32

The R value is an old LowRes trick where code logic for commands like IF actually work in 2 math values ... FALSE = 0 and TRUE = -1

Try these statements in an empty game...

PRINT 1=1
PRINT 1=2


was8bit 2020-03-08 23:34

So where it says IF R THEN it means IF R is true then... so giving R a value of 0 makes it mean FALSE and giving R a value of -1 makes it TRUE ;)


was8bit 2020-03-08 23:36

GFORCE handles both gravity and jumping .... i prevent jumping “again” if the block is already in the air...


defcon_zero 2020-03-09 00:15

Those explanations are really helpful, thanks again! And the true(-1) and false(0) trick is pretty cool! :)


defcon_zero 2020-03-09 00:44

Now, how would I make it to where the level ends when I touch the door? Would I use the existing collision system? Also, is it possible to go into a whole new level with a new BG and new palettes all in the same game code?


was8bit 2020-03-09 04:06

Yes,yes, and yes... give me a moment... ;)


was8bit 2020-03-09 04:30

Ok here it is.. I will explain more in the next post...


was8bit 2020-03-09 04:34

Ok, when you are in BG DESIGNER, you may make changes to and save to file your palettes and or your background...

What you may not have realized is that you can select an unused file and save ADDITIONAL palette files and background files...

... I have went ahead and created 2 extra of each for you, and quick edited them.. you can re-edit these yourself, BUT be very careful of... SAVE LOAD buttons, as well as selecting the correct file as it will let you save palette data to a background file, but then you get a corrupted background and you will have to redo it....


was8bit 2020-03-09 04:36

FILES are the raw data that have a # and a little title on top of the data...

You can access these and put these directly into active game memory, which expands your game... using other backgrounds has built in commands but using other palettes has to be done manually, but i figured out the proper game memory addresses for you :)


was8bit 2020-03-09 04:39 (Edited)

... so basically all you need to worry about is editing the additional backgrounds and additional palettes.... the game is set up to automatically advance to the next level...

If you want to add more, you only have 7 more unused files you may expand with..


defcon_zero 2020-03-09 14:26

WOW, this is all super helpful, thanks a ton! :)

I am making a new Atari 2600-themed level, and i want to make ladders that I can climb on. is there a way to do this? I'm guessing you would have to modify the collision system so that you don't collide with the ladders, and then make it to where you can press up to climb a ladder, but only on a ladder. I have no clue how to do this, however...


was8bit 2020-03-09 18:01

Ez... just a second...


was8bit 2020-03-09 18:18

Works best double wide :)


was8bit 2020-03-09 18:20 (Edited)

The section

SUB CHECKCELL(X,Y,R)

Is the place to check for char# placed with your BG DESIGNER and do somthing... here i simply set a truth flag variable and make use of it...


defcon_zero 2020-03-09 18:45

Wow, thanks again! How would you use another ROM entry with a new character set? I know how to use new palettes and BGs but not character sets.


was8bit 2020-03-09 22:11

Same trick as with the others, just a different memory address...

I went ahead and used DISK LOAD SAVE buttons in Char Designer to create a 2nd char set... then used this command, which you can move around and use it elsewhere...

REM 2ND CHARACTER SET
COPY ROM(8),$1000 TO $8000

Use this to reload original char set...

COPY ROM(2),$1000 TO $8000


defcon_zero 2020-03-10 01:30

Ok, thanks yet again! But what how do you figure out the $1000 TO $8000 part? I know it's loading memory, but how do you find the starting point and ending point of the data you want to get?


was8bit 2020-03-10 01:42

Happy to help :)

... ok, goto HELP section, and scroll down to MEMORY MAP


Memory Map
$0000 - Cartridge ROM (32 KB)
$8000 - Character Data (4 KB)
$9000 - BG0 Data (2 KB)
$9800 - BG1 Data (2 KB)
$A000 - Working RAM (16 KB)
$E000 - Persistent RAM (4 KB)
$FE00 - Sprite Registers (256 B)
$FF00 - Color Registers (32 B)
$FF20 - Video Registers
$FF40 - Audio Registers
$FF70 - I/O Registers


was8bit 2020-03-10 01:44

Character data starts at memory $8000
The next block of memory starts at $9000

So $9000-$8000 means the size of Character data block is $1000


was8bit 2020-03-10 01:46

COPY command...

COPY a,n TO d
Copies n bytes starting from memory address a to address d.

a is the data source
d is the data destination
n is the size or amount of data


defcon_zero 2020-03-10 01:51

Ok, that's nice to know. That clarifies things a bit. Your knowledge of NX is crazy, haha. :)


was8bit 2020-03-10 03:16

It took me awhile to wrap my mind around it ;)


defcon_zero 2020-03-11 15:46

Is it possible to make it where the player will only collide with BG cells that are PRIO 1? I want to try making good backgrounds, with large tilesets, but i don't want to collide with the back background. If that makes sense...


was8bit 2020-03-11 16:52 (Edited)

Since your player is a sprite, why not just use 2 backgrounds... use BG 0 to draw on the top layer, and BG 1 to draw on the back layer... i might use the top layer for collisions, so you would have to add BG 0 to the cell check to check for cells on the top layer...

You "CAN" read a priority setting, but using both backgrounds would be easier :)


defcon_zero 2020-03-11 17:52

Ok, so what ROM entry would that be in? Would I have BG 0 be the backgrounds I already have (for the platforms and collision), and then make a new background in whatever ROM slot i wanted, than just call it BG 1?


was8bit 2020-03-11 22:19 (Edited)

BG 0 and BG 1 are seperate from your background ROMS... both BG 0 and BG 1 have a visible portion as 0,0 to 19,15, but in memory NX give each a space of 0,0 to 31,31... it just that you can only see a smaller portion on the screen

BG 0 is layered over top of BG 1

SPRITES are placed on top of both...

... if you dont use the BG command, NX defaults to BG 0... but once you the BG command, NX will use the last setting for all CELL etc commands,regardless of where in the code the BG command is used, it will affect ALL such commands until another BG command is used...

It is best practice if you start using the BG command you use it often enough to make sure the CELL X,Y,cellnum and CELL.C(X,Y) commands are putting or reading to the proper BG layer



The only tricky command is CLS which actually will clear both BG 0 and BG 1... to clear just one use CLS 0 or CLS 1


was8bit 2020-03-12 15:22

I found a technical issue... for your game you will need to make this change

SUB CHECKCELL(X,Y,R)
C=MCELL.C(X,Y)
IF C<>0 THEN
R=0
END IF
END SUB

Change to...

SUB CHECKCELL(X,Y,R)
C=CELL.C(X,Y)
IF C<>0 THEN
R=0
END IF
END SUB



was8bit 2020-03-12 15:23 (Edited)

Check out the SPIKES and GOLD i added...

https://lowresnx.inutilis.com/topic.php?id=1060


defcon_zero 2020-03-13 13:55

Ok, i'll try doing that.

Wow, that's a small difference. What exactly does it change?

yes, I saw that. I might try making a key or something at some point...


was8bit 2020-03-13 15:39

These are processed abit differently


Log in to reply.