Log In  

Hello there, I am a total noob when it comes to Lua and Pico 8 but I have been trying to get past my own limitations.

However I kind of need help finding a better direction to code everything. I know there are demos and countless searches on the internet keep telling me to look at them but everything is so short hand that even JELPI is ridiculously complex looking.

Like I want to learn, but a lot of things with the code in JELPI might be too optimized for me to get just be glancing at it.

This is what I have been working on:
link my P8 file
><
Still don't know how to get embed...

Just looking at the code there is some problems as using booleans like that allows the controls to break down due to holding down a button. Was trying to fix that.

Again I am really trying to start from Zero experience so it would be great if you know of good video/material/forms that cover this too. While looking at other people's code is neat and all... if I cannot read it... it does not help.

Thanks for the help I really want to hopefully make something soon.

P#49437 2018-02-19 21:00 ( Edited 2018-02-20 02:00)

I'm pretty new to game programming too (I don't have any real knowledge of techniques, I just make stuff up as I go along), but I'd like to try and help. I looked at your code, what are you trying to get it to do exactly? I see some lines that don't appear to do anything, mostly in move().

P#49440 2018-02-19 21:36 ( Edited 2018-02-20 02:36)

This I am just getting the basic movement sets done.

with move() that is basically cycling the animation for the walking input.

I watched some tutorial on adding animations but they went for more of a linear loop and I noticed that there was some issues as to sprites were selected. So I made an identifying class called player.anime that was to clean up where on the sprite sheet I could select from.

The rest is just me trying to program a ping pong animation cycling through 3 frames.

I might have to just break it down in the sprite sheet to make it more of a simple loop. Even then the timing is a little bit fast...

P#49441 2018-02-19 23:04 ( Edited 2018-02-20 04:04)

If you want a looping animation you need set a sprite for each frame

next, use this function and code

local a=nil

function animation(low,high)
 if a>then high then a=low else a+=1 end
end

function _update()
 animation(low,high)  --relace the low and high with the two numbers
end

function _draw()
 spr(a,x,y) --replace x and y with your own varibles
end
P#49508 2018-02-22 15:07 ( Edited 2018-02-22 20:07)

I got to manage the animation sequences by setting a variable (player.frame) and assigning a tileset frame to it, so it looks like:

player.frame=1

Then I created a function that adds 1 value to that variable so it changes the frame to the next one on the tileset:

if (btn(1)) then player.frame+=1 end

So there's a point where yo need to loop, right? let's suppose that your animation uses 4 frames, so you need to tell that when it reaches the last frame you're using for the animation it goes back to the first one. Something like:

if (player.frame>=5) then player.frame=1 end

--if you use for example the frames from 1 to 4 the greater/equal condition (>=) applies for the next frame (5) to make it work. Not pretty sure why ¬¬


I found this thread interesting because I'm a totally noob at programming since I've always used visually assisted frameworks (such as C2) for my games, so I feel kinda challenged and frustrated with P8/Lua, specially when trying to resolve "apparently" easy things with code.

Speaking of which, have you guys managed to flip or rotate sprites when pressing the direction buttons in a simple way? If so please, give me some tips! Thx

P#50215 2018-03-10 20:18 ( Edited 2018-03-11 01:18)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 21:24:02 | 0.007s | Q:16