Playmaker Forum

PlayMaker News => General Discussion => Topic started by: upOwlNight on May 15, 2014, 05:14:40 PM

Title: PlayMaker/Programming Fundamentals. Is this acceptable?
Post by: upOwlNight on May 15, 2014, 05:14:40 PM
I'll keep it short as possible. I often run into situations while using PM like this and always feel like I'm doing something wrong. I'm always thinking I'm not being efficient enough or my code is too sloppy. Here's an example I'm hoping you can look at. Let me know what kind of suggestions you have.

I have squares that spawn (using a spawn pool).
Each square starts on the right and moves to the left.
There are 65 Possible positions 5x13 grid.
I have an array list with every position on it called all positions
When a tile spawns on the right side I look through the array list of all positions for all the positions that match the spawned tile's row (in this case that is the Z axis)

All matching z axis are added to a new array list called possible positions

I iterate through the possible positions list taking the x (right to left value) from each vector 3 and adding it to a new list called possible positions x

now that I have an array with only floats I "array list sort" it and it puts the lowest value on top

Next, now that I have the lowest X value, I know which value is in the same row as the spawned tile, and of those, which is the furthest away.

I reassemble the y and z to my new found x, and use this vector 3 as my position to "move to".

I remove this vector 3 from the all position list, so the next tile that spawns in the same z (row) wont consider it.


This seems like such a long process to me, and I'm terrified that once I finish my game is going to be clunky
Title: Re: PlayMaker/Programming Fundamentals. Is this acceptable?
Post by: Marsh on May 15, 2014, 07:43:37 PM
Im sure there is a better way to do it, but at the end of the day your not a programmer. In a huge project yes this would bog it down. Going through 65 solutions? That is tiny. I doubt you will run into any problems whatsoever.


As long as you dont have any triple for loops in your update function you will be fine.
Title: Re: PlayMaker/Programming Fundamentals. Is this acceptable?
Post by: upOwlNight on May 16, 2014, 12:13:11 AM
Thanks for taking some time to look through that :)

what's a triple for loop?

I know I will have to do a couple more iteration type things similar to this for other scenarios.

Later I'm going to have to make a method for moving a tile up or down. It's going to need to make sure nothing in the row above it has the same x value plus or minus half the width of the tile.