• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Handling version of objects?

M

Munch

Guest
What is better practice?

Currently I am giving an object different values, depending on the sprite I choose.
For example an object "car", that has the variable weight and speed, which get set depending on the sprite it gets.

or

do I create one parent object (with standard variable / functions) and an child object for every sprite/car I have with already set variables?

or something completely different?
 

Rob

Member
There are plenty of ways to do it.

Personally I would store all the car data in an array or grid (and you can create the grid by importing a .csv file) and just have one object for cars with each car being a different instance of the same object but with stats and sprites dependant upon its index in the array/grid.
 
M

Munch

Guest
There are plenty of ways to do it.

Personally I would store all the car data in an array or grid (and you can create the grid by importing a .csv file) and just have one object for cars with each car being a different instance of the same object but with stats and sprites dependant upon its index in the array/grid.
Alright, thanks!

And what if some would have different functions?
For example:
95 cars just drive straight forward
3 drive in circle
1 follows another object
1 makes a left turn every 10 seconds

Would I code every function into the car object and save them as boolean values in the data grid?
Or would I create child-objects for every extra function?
 

Rob

Member
Alright, thanks!

And what if some would have different functions?
For example:
95 cars just drive straight forward
3 drive in circle
1 follows another object
1 makes a left turn every 10 seconds

Would I code every function into the car object and save them as boolean values in the data grid?
Or would I create child-objects for every extra function?
Yeah you could use states for the different functions and go from there, all inside the same object.
 
Top