New games every week!
PRC2 : Day 4 : Still More Sokoban
3rd March 2009  
Yeah, I figured I'd forgotten a few things, and as Sokoban gets built up, slowly but surely, all the forgotten things are poking their heads out, waiting to be sorted.

Click inside for coder-heavy stuff.. or just grab Sokoban from earlier today and play that for a while!!
-=-=-

For starters, a single map's not enough.
I mean, it's ok, but if you want a background and a foreground, and a bunch of things flying/running around, then it's not.

For Sokoban it's simple.. Map, Crates on top.
For Mario it'd be harder.. Map, Running enemy on top.
For Micro Machines you've got Foreground, Background, cars.
and so on..
(That doesn't mean they're going in! They're just examples!! Calm down!!!)


So, to allow for a lot more elements, I've added four large arrays..
int AA[65536];
int AB[65536];
int AC[65536];
int AD[65536];

Nice big chunky arrays, taking a pretty darn big chunk out of the DS's memory.
64kb*4byte (int) * 4 arrays = 1Mb worth of space taken up.
Why would I do that? Well, it's pretty simple, really.
I can reuse that space over, and over again, in all kinds of different areas.

In our most basic example, Sokoban..
1. I'll be using GM(x,y) (General-Map) to find a position on a 256x256 map, inside the AA array.
2. I'll place the crates onto AB[], and use GO(Object,Param) (General-Objects) to find an object and it's needed parameters. (x,y,shifted x and shifted y)

Then, come the next game, I can flush it out quickly, and reuse the memory as needed.
I've added GW (General-WideMap) and GH (General-HighMap) for really long and tall levels (Mario, Ice Climber) so I should be safe with about 99% of game type.
Except 3D.. But we'll just skip past that idea


So, with the mega-sized arrays in the game, I've now started work on some basic reusable scrolling map techniques.. Again, sticking with the GM/GW/GH functions.

Once that's all working I might finally get around to making that Sokoban!!

Views 54, Upvotes 7
Platdude Retro Collection 2
New games every week!
Site credits : This was all done by Jayenkai
(c) Jayenkai 2017 and onwards, site design Rychan. RSS feed
Blog - PRC2 : Day 4 : Still More Sokoban - AGameAWeek