Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Platforms and ladders
#7
(01-04-2024, 10:49 PM)johnno56 Wrote: Gotta love the platformers.... Nicely done!

Question: Why use 'json' format for the level files? Smaller size? Easier to 'translate/interpret'? Not judging... just curious. I am so used to using the plain text 'grid' file... lol

Hi,

I'm gladly provide the map in a plain text grid file .... especially for you  Big Grin
Code:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 2 1 2 2 2 2 2 2 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0
0 0 2 2 2 2 2 2 2 1 2 2 2 2 0 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0
0 0 0 0 2 1 2 2 2 2 2 2 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Oh, no...what are those ?  Big Grin You may translate this 0,1,2 with a Tilemap Editor  Big Grin Big Grin Big Grin

Actually, I challenged myself to rewrite the Platforms and Ladders using a Tilemap as an alternative to JSON map format.
This Tilemap version is made just for fun only and it serves as a proof of concept using Tilemap Editor
The most important thing, it's an awesome experience to play around with Naalaa
Added features :
- climb up a ladder easily (if stuck, just use LEFT and RIGHT keys)
- No more avoiding an enemy, you have automatic bullets to shot.

You may try the Platforms and Ladders in Tilemap version [ File : recreate_platforms_and_ladders.zip  ]

I thank a lot to Marcus for providing all the resources I need to learn the OOP style (wanna-be OOP  Big Grin ) which I used during the rewrite of the game. 
Code:
'----------------
' INITIALIZATION
'----------------
...
'load and setview map created with Tilemap Editor
TM_LoadMap("assets/map.txt");TM_SetView(0, 0, width(primary), height(primary))

'Sprite Class definition
Sprite =
    [
        '---Properties---
        'position (x,y) and size(w,h) are used in collision detection
        'dx and dy are movement direction in horizontal or vertical,baseCel refers to spritesheet
        img:0,x:0,y:0,w:0,h:0,dx:0,dy:0,baseCel:0,       
       
        '---Methods---
        SetDx       : function(deltax);this.dx=deltax;endfunc,
        SetDy       : function(deltay);this.dy=deltay;endfunc
    ]
   
visible Player = copy(Sprite)   'Player Class inherit properties and methods of Sprite Class
visible Coins = fill(Sprite,10) 'Coins Class has 10 objects, uses Sprite Class as a template
visible Bullet = copy(Sprite)   'Bullet Class uses Sprite Class as a template
visible Enemy = fill(Sprite,5)  'Enemy Class has 5 objects, uses Sprite Class as a template
...  

'--------------
' MAIN PROGRAM
'--------------
do
...
    PlayerMovement()
    UpdateCoins()
    UpdateBullet() 
    UpdateEnemies()
                                               
    foreach i in Coins draw image i.img, i.x, i.y, i.baseCel  'there are 10 coins
    foreach i in Enemy draw image i.img, i.x, i.y             'there are 5 enemies
    draw image Player.img, Player.x, Player.y, Player.baseCel 'only 1 player
    draw image Bullet.img, Bullet.x, Bullet.y                 'only 1 bullet
...
until keydown(KEY_ESCAPE,true)

Happy Weekend to everyone,


Attached Files
.zip   recreate_platforms_and_ladders.zip (Size: 18.86 KB / Downloads: 5)
Reply


Messages In This Thread
Platforms and ladders - by Marcus - 01-04-2024, 05:20 PM
RE: Platforms and ladders - by johnno56 - 01-04-2024, 10:49 PM
RE: Platforms and ladders - by Marcus - 01-05-2024, 05:54 PM
RE: Platforms and ladders - by 1micha.elok - 01-13-2024, 09:09 AM
RE: Platforms and ladders - by johnno56 - 01-05-2024, 07:32 PM
RE: Platforms and ladders - by 1micha.elok - 01-08-2024, 01:51 PM
RE: Platforms and ladders - by johnno56 - 01-09-2024, 03:59 AM
RE: Platforms and ladders - by johnno56 - 01-13-2024, 07:29 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)