Log In  




I've got this grid of "slots" for enemies which I initially created using a start_x and start_y position and a couple of nested for loops to create the rows/cols with the start_x / start_y being the top left for the starting position of the grid.

But now I wanted to create the same grid but relative to an origin point at the centre - my thinking was I could increment this single point and move the grid around and maybe use sin/cos to have the slots rotate around the origin for some fun enemy patterns.
I didn't really know how to do this, so I just modified my x/y starting positions until I could get two short lines of code for the initial X/Y positions that worked. This looks fine until you move the origin point which then lags behind or in front of the actual grid.

My math is awful, so I don't really know what I'm doing wrong. I figured if the initial grid looked okay relative to the origin, I could just change the origin values and everything would fall into place at the new position in update(). But not so.
I assume it's the way I'm creating the initial X/Y positions, but I don't know how to fix it neatly.

Can somebody more math-inclined help me out?


function _init()

function init_inv_slots()
 local i_num=1
 local width=8
 local height=7
 for r=1,4 do
  for c=1,8 do
   local i={
   x=grid_origin.x-(c*10)+(grid_origin.x/2)+13, -- Problem here
   y=grid_origin.y-(r*10)+(grid_origin.y/2)+5,  -- Problem here

function _update60()

function update_inv_slots()
 if btn(0) then grid_origin.x-=speed end
 if btn(1) then grid_origin.x+=speed end
 if btn(2) then grid_origin.y-=speed end
 if btn(3) then grid_origin.y+=speed end
 for i in all(inv_slots) do
  i.x=grid_origin.x-(i.col*10)+(grid_origin.x/2)+13 -- So will be problem here too. 
  i.y=grid_origin.y-(i.row*10)+(grid_origin.y/2)+5 -- and here. 
  --if ((i.x+speed)+(i.w/2)>127 or (i.x+speed)-(i.w/2)<0) then
  -- speed=-speed

function _draw()

function draw_inv_slots()
 for i in all(inv_slots) do
P#64887 2019-05-31 11:50 ( Edited 2019-05-31 12:52)

Can somebody explain why my steering code (well, @2darray's mostly) sometimes goes bananas and sine's itself off-screen rather than heading to the next waypoint? It only happens occasionally and I can't see why and always to the left.

Cart [#nokikfiyu-1#] | Code | 2019-05-09 | License: CC4-BY-NC-SA | Embed

Sometimes it'll do this...

Would greatly appreciate any help and a math explanation. It seems to happen more often if I decrease the turning speed from say




but that doesn't explain the example gif because the distance between node 5 and 6 is quite far.

Edit: I've uploaded a version with a simpler sprite and a vector to show the current target node.

P#64258 2019-05-09 13:58 ( Edited 2019-05-09 14:57)

Apologies if this is common knowledge and I asked on Twitter as well, but...

Is it just me or does anybody else get extreme audio stuttering on Android with Chrome on the web export? This has happened across three diffferent phones and three Pico8 versions. Audio is fine on Samsung's browser and Edge mobile. Was there ever a fix for this that I missed?

P#64162 2019-05-03 11:11

Cart [#53607#] | Code | 2018-06-16 | No License | Embed

1.1 update:

  • Code optimisation
  • Muted alert sound for low fuel/ammo
  • Reinstated original title screen (much better!)
  • Added btn(5) X as alternative acceleration button for those using joypads/sticks.

My third little game - an arcade racer / shooter a bit like RoadBlasters, which was a favourite of mine as a kid.

Up = Accelerate
Down = Brake
Left/Right = Turn left / right
Z = Shoot
X = Alternative accelerate

Hope you enjoy it. Don't bother asking for improvements, I'm at the token limit :D On to the next thing!

P#53292 2018-06-05 11:57 ( Edited 2018-06-17 07:21)

Cart [#52771#] | Code | 2018-05-15 | License: CC4-BY-NC-SA | Embed


I am reduced to asking for help with the above. Pressing Z fires projectiles to a target XYZ that is Z+10 units "into" the screen (denoted as white targets). This is fine when the target X matches the source X (the player, basically) but when firing to the sides (+/- 150 units) the speed is very slow and I'm somehow able to fire much faster than I should be able to.

The relevant stuff is in update_bullets().

I'm using a fairly standard algo for moving towards a target that I'm pretty sure I used before for 2D stuff but I can't make it work in "3D". I assumed you just swapped out the Y for the Z.

Can somebody help me out?

Z = Fire
Left,Right = Shift the targets 150 units to the left or right.

P#52773 2018-05-15 07:56 ( Edited 2018-05-15 18:56)

Hi guys,

So I'm developing my third game and actually reading the docs this time around and I'm now using the stat() function to see what's going on as I code.

I've got about 284 lines of code and a spritesheet of 785 bytes. No music or sound effects. Yet my mem usage is 43MB according to stat(0). Isn't...that a lot? Seems like a lot. What's going on here? Is it measuring the entire PICO-8 development environment usage or just my code?

Also, stat(1) for CPU usage from the docs states that a value of 1.0 is the program executing 100% of the time between frames, whereas anything over 1.0 is basically frame-skipping due to excessive load. I've of a value of 0.19. I'm guessing anything under 1.0 is "this is way easy, what else you got?" from the CPU, correct?

I've also been looking at the PICO-8 cheat-sheet and noticed the memory layout. And I know people use peek/poke/memcpy/memset to do....stuff. Why would I need to know the memory layout for PICO-8 and why is manually fiddling with the memory desirable? Procedurally generated graphics? Anything else?


P#48514 2018-01-24 14:40 ( Edited 2018-01-25 11:05)

Cart [#42131#] | Code | 2017-07-01 | No License | Embed

My second game - my version of Missile Command. I learned a fair bit doing this one so I hope you like it :D
Much like nuclear war, there is no win state, you just survive as long as you can whilst things get progressively more difficult.

The aim is to keep your cities safe from ICBM attack. You have a limited number of ABM missiles. As long as one city survives each wave, you can continue. Destruction of ABM launch silos means you cannot use it although they are more hardened than cities against a direct impact. Bonuses are awarded for each surviving city.


Z to start game
X to fire ABM missiles

This is so much fun, on to the next project!

P#42132 2017-07-01 18:50 ( Edited 2017-07-02 09:26)

Hi, sorry if this is a stupid question because I'm not really a web developer but I've hosted my game on my own site and it doesn't behave the same as the same game hosted here. Desktop is fine but on mobile, the on-screen touch controls are missing and I have to pinch to zoom to get the game to fill the window while on here it fits neatly even without using full-screen mode.
Can someone point me in the right direction? I'd like my Pico8 games pages to be mobile-aware.

I don't know if this is something I need to change with the export or what. I'm game to learn "proper" web development....I know some basic HTML and that's it but I'm up for getting my hands dirty if someone can point me in the right direction.

Also as an aside, I couldn't figure out how to post here without switching mobile Chrome to the desktop version. You can't seem to post otherwise.

P#38882 2017-03-30 13:45 ( Edited 2017-05-18 11:25)

I know this isn't strictly speaking Pico-8 related but I'm not much of a programmer and I get the feeling that a lot of the clever techniques that I see used here are...um...algorithmically standard things in terms of doing 2D graphics and movements and things like that and can probably be used in any 2D game programming language/library.
Does anyone know of any 2D gamedev resources to learn more that explain the math/algorithms involved in simple 2D games and effects? I've done exactly one game in Pico8 and it took a very long time because I don't know how to implement things that appear to be standard 2D videogamey things. Absolutely everything I know about game programming is in that game and it's basically just Pong (again).

Sorry for the off-topicness and potentially vague question.

P#38817 2017-03-28 15:12 ( Edited 2017-03-28 19:12)

Cart [#38726#] | Code | 2017-03-25 | No License | Embed

First Pico-8 game. Sorry it's Pong/Arkanoid again :) This is pretty much done simply because I can't think of anything else to add. I had to learn Lua at the same time so the code is probably pretty horrible. I'll update it for bug fixes and that but I'm probably going to move onto something else after this.

  • 16 levels.
  • 7 power ups.
  • Persistent high-score.
  • Whizzy particles.

Yeah, I guess that's it. Many thanks to the Pico-Hero guy for getting me started.

P#38727 2017-03-25 14:52 ( Edited 2017-04-18 16:43)


I'm trying to record an animated GIF under Linux in PICO-8. It records it fine according to PICO-8, but I have no idea where the file is located. I've done a file search for GIFs under my user directory and nothing turns up. Nothing under $HOME/Desktop where I'd expect it to be.

Little help?

P#38712 2017-03-25 09:30 ( Edited 2017-03-25 13:30)

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-06-26 06:08 | 0.093s | 4194k | Q:74