Log In  
:: Unfold ::

I am struggling to wrap my head around creating a function to search though a table for matching positions and then replacing the matching value with a new value.

The idea is for a simple racing game. Every time an obstacle/car leaves the screen it is deleted from the table and new obstacle/car is generated with a new position.

The new position is randomly picked from a list of pre-chosen positions. But this means that there are occasions where the obstacles/cars overlap because they have randomly picked the same positions as an existing obstacle/car already in the table of obstacles.

My rough concept of the idea runs like this...

  • Create obstacle table
  • Create new obstacle
    • Check if obstacle table is empty - add new obstacle
    • If not empty
      -- Loop through table of obstacles and compare x/y pos values
      -- If a match is found(overlap) then change the x/y pos of the new
      obstacle BEFORE adding it to the table
      -- Maybe loop again to perform another check???
P#137800 2023-11-23 05:02 ( Edited 2023-11-23 05:03)

:: Unfold ::

Cart #farmbot-3 | 2023-11-23 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA


Hey. This is a toy and not a fully fledged game. I was working through @SpaceCat tutorial on YouTube and developed a touch further than where he left off. I learnt a lot from his video as well as, I have to give a shout out to @Lazydev and @DocRob. They all have amazing informative channels on YouTube as well.

EDIT: Also I forgot to thank NerdyTeacher as well. I yoinked the LERP function from the PICO VIEW web zine. Would really be awesome if there was a PDF/printable version of PICO VIEW. Being out at sea with bad internet makes looking up reference hard.

Like I said, this is a toy. I am still learning a lot and have only completed one Fantasy Console game (CHIPPY - LowresNX). But I have to admit that this is far too addictive playing with Pico8.

I dabbled with adding caterpillars as "enemies" but haven't taken it further than spawning them.

V1 - I have added some sounds to play around with the feel. I have also looked at adding character portraits.

  • LEFT/RIGHT/UP/DOWN (Movement)
  • Z/O (Selection in the hotbar/Action in menus
  • X (Action button in game/Open+Close menus
P#137514 2023-11-16 10:09 ( Edited 2023-11-23 05:26)

Follow Lexaloffle:          
Generated 2023-12-11 08:26:30 | 0.138s | Q:13