Log In  

Cart #kmazkohi-0 | 2020-01-26 | Code ▽ | Embed ▽ | No License

The game is built on Zep's Collide.p8 demo. I'm basically placing "Items" (Musical Note etc.) into the map at specified locations marked by Red Squares. I have a function which basically checks for the Coordinates of the Red Squares, which it stores in a table and reduces to just 6 locations which are ordered randomly each time.

The problem is that all the Item data is in _Init() and cannot be anywhere else, and the Location data is made in a function. So everytime the game loads, the Items are in the same default position in the Table which they are set to.
How can change this so the Locations are sorted and randomized first, or is there anything that can be done to fix this?

(To navigate the cart: Orange Numbers are Player Coords, Yellow Numbers are the Coords of the second Item in the "ILoc" table.)

Many thanks.

P#72258 2020-01-26 17:26

:: FibS

Cart #zuwusidegi-0 | 2020-01-26 | Code ▽ | Embed ▽ | No License

All changes made are on tabs 0 and 1. (I commented them.)

My solution is, essentially, to place the location-clipper in the init function and remove it from the update function. I also redid the location-clipper function itself.

I made some mild edits to the actor constructors for efficiency. Most notably, iteration now builds all six items with 3 lines instead of the several needed per actor previously. I did this because I needed to be sure all six actors were receiving different positions, not merely the three present before.

All changes are on tabs 0 and 1. I have left the rest of the code completely as-is.

P#72259 2020-01-26 18:42

@FibS I cannot thank you enough for this solution! Your code is absolutely immaculate, works like a charm too. The efficieny edits are incredible too, many thanks again!

P#72309 2020-01-27 21:31

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2022-01-26 00:14:20 | 0.034s | Q:23