New games every week!
Petit Switch - Session Six - Framework Blog
24th May 2019
So, today I wrote a basic minimal Framework in PetItC4 with simple enough functionality, but hopefully enough to allow for lots of variety in future projects.

I've added a basic DrawImg thing, along with my usual set of SetCol, SetAlpha, SetSize and SetRot commands.
I've created a sprite loop to draw sprites when required, and blank out any unused sprites at the end of the loop.
I DID originally try adding a SPCLR (clear all sprites) at the top of the loop, but that flickered horribly. You're not meant to do it like that
A little optimisation and things now seem to be running smoothly.

-=-=-

Findings

Sprite ZOrder
Sprites with a lower ZOrder draw on top.
You can specify the ZOrder using SPDef x,y,z where x,y are obvious, and Z is between 4096 and -4096, with the lower value being "on top"

By default Sprite 1 is above Sprite 4000, so "normal" drawing needs to be done with their sprite values set to reverse. I.e. since I typically draw backgrounds, then characters, then foregrounds, I need to start at sprite #4000, then go down to 1. It's quicker to do it that way, than to have to respecify the ZOrder, all the time.


Screen Size
The XScreen Width,Height command can seemingly take anything from 128x128 to 1280x720, but I've stuck to 424x240 which seems to fill most of the screen, whilst keeping things "chunky" enough that a standard set of unscaled 16x16 sprites are all recognisable on the screen.
There are additional parameters to XScreen, adding different graphic scaling techniques to the engine.
Have a play, and see what looks best for your game.

The TScreen function will change the text size.
Select a font size (8 or 16), then the size of each grid point on your screen.
It's kinda quirky how that works, and I broke it quite a few times, but if you're using a large screen size (eg the full 1280x720) then you're probably going to need to look into this.

FWI : My defaults are
XScreen 424,240,2
TScreen 16,8


Controller Quirk
The left JoyCon's dpad doesn't seem to let you hold left and right at the same time..
This kinda makes sense, since.. you know.. it's meant to be a DPad, innit!!
But.. if you're doing a 2 player, 2 JoyCon game, you might need to be able to hold those buttons together.
Probably best to keep this in mind when making some games.
Further experimentation will be required, methinks!


Clearing the Spritesheet
Finally figured this bit out!!
Start a new project, hit F4 to go to Direct mode, type
GTarget 4
GCLS
Then hit F10 and you'll have a blank spritesheet to start with, instead of that giant sprawling sheet full of default sprites..
Save it, and then you're dealing with that, instead!

I think that's pretty much all I've learned, today.
Been a fun day of experimentation!
Views 106, Upvotes 12  
Daily Blog , Petit Computer , Smilebasic , Nintendo , Switch , Petit Switch , Petitcom4
New games every week!
Site credits : All of the above : Jayenkai
(c) Jayenkai 2023 and onwards, RSS feed

Blog - Petit Switch - Session Six - Framework - AGameAWeek