Log In  

Hey guys,

I am new to programming in general and started coding with the Pico-8 a few days ago. I did read/watch a lot of tutorials and got some small "games" already working. I want to take it slowly so that I understand what I am doing. My main goal is to program a simple jump'n'run game.

Now my questions is: Is it possible to add certain things (modules) to my existing code (basic movement with walking animation) or do have to to re-code everything when things get more complicated? I am asking since I did two tutorials. The first one did movement like this (example for left button)

 if(btn(0)) player.x-=player.speed

Then I read another in the fanzine #2 where movement was done in a way I could not follow. The author used different states for walking, jumping and being idle. The whole thing was called "finite state machine".

Now I am unsure about two things: Does the first approach allow jumping, falling, etc or do I have to work with the states? Secondly, I would like to add things like particle effects or shooting bullets to my game. Can these (and other) modules (do not know if that's the correct expression) be simply added without having to re-code everything?

Tl;dr:

  1. Can things like jumping, falling etc. be added to the abovementioned example for movement?

  2. Can modules like shooting bullets, particles, enemy ai etc. be simply added to the existing code or do they need a whole different "frame" each depending on how they work?

I hope my questions are clear and they are not too nooby. Thanks in advance for your answers.

P#38507 2017-03-21 10:22 ( Edited 2017-03-23 07:20)

Hi there and welcome!
This really depends on what you call a 'module' and how you would use them. Basically any part of features could be incapsulated and put as a module and it is a good practice to do so but not always ofcourse.
Anyway as much as I know there is no right way to do it. It's only you to define the rules your game runs.
So you should probably study each part of code to understand how it works and only them you could say if it needs some adjustment. And it most likely will.
Feel free to ask something specific, I ll be glad to help

P#38508 2017-03-21 10:57 ( Edited 2017-03-21 14:57)

Hello and welcome ^-^

I myself am new to PICO-8 as well, though I've been coding for many years.
I'm a Software Dev by profession and love teaching/coaching others

If your goal is to make your code as modular, readable, and re-usable as possible, using states/a finite state machine as well as breaking the code that would otherwise be copied elsewhere in the file out into functions (what I believe you mean by "modules) that you can call whenever you want to create a bullet or jump or anything else, would be the best way to accomplish that.

Sorry if that was way too much info to pack into a single run-on sentence haha. Let me know if anything is unclear, and please don't hesitate to ask any other questions either!. Ask away!

~Skel

P#38535 2017-03-22 03:06 ( Edited 2017-03-22 07:06)

Thanks for your answers, I really appreciate them!

@ Skelteon:

"If your goal is to make your code as modular, readable, and re-usable as possible, using states/a finite state machine as well as breaking the code that would otherwise be copied elsewhere in the file out into functions (what I believe you mean by "modules) that you can call whenever you want to create a bullet or jump or anything else, would be the best way to accomplish that."

This is exactly what I want. I want to have certain functions which can be added to the existing code without having to change it, and maybe even be used these for other projects. If a finite state machine is best for this work flow, I probably have to work my self through the tutorial in the fanzine. It would be great if this structure is possible, so that I first program basic movement, then maybe shooting bullets, enemys with ai, etc.

I am so eager about this since my first week with pico-8 was a bit disillusioning. I looked up how to move a sprite, then how to do basic animation (circling through sprites while moving). Then, I wanted to know how collision with the map works, but in the corresponding tutorial movement was totally different then the way I did it. Same went for animation. Then, in the fanzine, static machines were introduced and they did movement different again (at least that's how I perceive it), And so it felt like I learnt things which do not really add up to some kind of learning curve.

@TriBar: Thanks for your answer as well. I used to have a specific problem, but now it seems that I have to redo everything so it will take some time until I have to ask something specific again ;)

P#38580 2017-03-22 17:53 ( Edited 2017-03-22 22:16)

@ Olivander12
You're most welcome! I looked up the fanzine you were talking about (should read those myself since a lot of cool stuff there), the example you described was probably PicoJump.
So, to ease some pressure as I already said there is no right or wrong way to do it. It is all situational. In my project Xusha seems like I "reinvented" the FSM method since it seemed a most proper way to do it.
All the coding starts with paper. First you should figure out the scope of your game. The reason for using FSM concept is mostly for processing different behaviors depending on current state. Say if you don't want to allow to shoot while jumping you should track somehow the jump state.

P#38606 2017-03-23 03:20 ( Edited 2017-03-23 07:20)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-19 20:19:11 | 0.015s | Q:13