• Hey! Guest! The 37th GMC Jam will take place between May 28th, 12:00 UTC and June 1st, 12:00 UTC. Why not join in! Click here to find out more!

GMS 2 Handling version of objects?

Munch

Member
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.
 

Munch

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.
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