Introduction
Micro Jam #41 is happening once again.
This time the theme is Platformer. Last time when I participated, I lost badly, but I gained enough knowledge that was worth the Loss.
So I decided to try this jam again, and this time, help you too.
In this blog. I am gonna tell you how you could make a simple platformer controller for your game in Mini Micro.
If you prefer to learn visually, I suggest checking out my video on the same topic -> How to Create a Platformer Controller in Mini Micro
Platformer Controller
In most engines and frameworks, this is a very hard task, but why?
Because you have to code every single thing,
Collision, Ground Detection, Movement on keys, and Jump Mechanism.
But Mini Micro takes a special approach, which makes the creation of a platformer controller way easier
See, there is a library in Mini Micro in /sys/lib
called spriteControllers
. This library has everything you need for creating a platformer sprite controller.
// Set up our player character, "Kip"
newAnim = @spriteControllers.newAnimation
kip = new spriteControllers.Platformer
display(4).sprites.push kip
kip.x = 400; kip.y = 80
kip.idleAnim = newAnim(file.loadImage("/sys/pics/KP/KP-stand.png"))
kip.runAnim = newAnim([
file.loadImage("/sys/pics/KP/KP-run1.png"),
file.loadImage("/sys/pics/KP/KP-run2.png")], 10)
kip.jumpUpAnim = newAnim(file.loadImage("/sys/pics/KP/KP-jump.png"))
kip.fallDownAnim = kip.jumpUpAnim
kip.climbAnim = newAnim([
file.loadImage("/sys/pics/KP/KP-climb1.png"),
file.loadImage("/sys/pics/KP/KP-climb2.png")], 10)
kip.curAnim = kip.idleAnim
// Main loop:
while true
spriteControllers.updateSprites 1/60
yield
end while
THIS CODE IS TAKEN FROM THIS BLOGPOST I HIGHLY RECOMMEND TO CHECK IT OUT TOO - HWYDT: Donkey Kong
Jam is a time when people are usually in a rush (Especially if it's for 48 hours). So I have answered some questions below before explaining the logic.
How to Turn Off Climb?
Just delete this part from your code
kip.climbAnim = newAnim([
file.loadImage("/sys/pics/KP/KP-climb1.png"),
file.loadImage("/sys/pics/KP/KP-climb2.png")], 10)
What if this code doesn't have the logic I want?
Mostly Everything You need would be available in the library, so make sure to check out /sys/lib/spriteControllers
, but if it's not, then you have to create your functionality
Explaination
- This code sets up a player character named "Kip" game using a
spriteControllers
system. - First, it initializes Kip as a
Platformer
sprite inspriteControllers
and adds it to the display layer. The character's starting position is then set to (400, 80). - The code then defines various animations for the player: an idle animation, a running animation, a jump animation, and a climbing animation.
The main loop runs continuously, updating all sprites at 60 frames per second (FPS) by calling
spriteControllers.updateSprites
with an argument of1/60
.
Outro
If you do have any doubts, write them down (I promise I will try my best to help you).
To get more in-depth details about spriteControllers
, make sure to check out
-
spriteControllers.ms
in/sys/lib/
- Platformer Controller
- HWYDT: Donkey Kong*
Till then stay awesome, Best of the luck for the game jam and BYE