• 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!

Legacy GM how can i make a ds_grid like this?

B

Barack Pálinka

Guest
Hi,i'd like to make a skill bar which is 3 cell wide,but i don't know how to dot it.
And also i'd like to attach objects inside the cells.
It should look like this:View attachment 11627
Thanks in advance!
 
B

Barack Pálinka

Guest
why not use array?
I'd like to create a skill panel and when the player clicks on a skill it would upgrade and the player could jump higher and etc.
And i don't really know how to use an array.
 

sylvain_l

Member
I think you are already confusing things between the screen visuals and your game engine data/structure.

are those skills belonging to the player, or what? or to the visual "skill bar" ?
 

Zhanghua

Member
array is just a memory data in your game.
The Skill design is similar to the item design.
For example With the object oPlayer:

Create Event:
Code:
var skill1 = instance_create_depth(0,0,1000,oSkill1);
var skill2 = instance_create_depth(0,0,1000,oSkill2);
......
//PS: oSkill1 and oSkill2 have same parent obj oSkillPar.
oPlayer.SkillInfo = [  skill1, skill2,.......  ];
Then you can operate these skill event in other player event.

Such as Draw_GUI Event:
You can get the sprite of the first skill oPlayer.SkillInfo[0].sprite_index to draw upon your gui.
Or just place the skill objs on the Draw Event
 
Last edited:

Yal

🐧 *penguin noises*
GMC Elder
ds_grids are basically just a data structure to store data, arrays can do the same things but are easier to use. You shouldn't mix up abstractions with what the things actually are...
 
B

Barack Pálinka

Guest
array is just a memory data in your game.
The Skill design is similar to the item design.
For example With the object oPlayer:

Create Event:
Code:
var skill1 = instance_create_depth(0,0,1000,oSkill1);
var skill2 = instance_create_depth(0,0,1000,oSkill2);
......
//PS: oSkill1 and oSkill2 have same parent obj oSkillPar.
oPlayer.SkillInfo = [  skill1, skill2,.......  ];
Then you can operate these skill event in other player event.

Such as Draw_GUI Event:
You can get the sprite of the first skill oPlayer.SkillInfo[0].sprite_index to draw upon your gui.
Or just place the skill objs on the Draw Event
i think instance_create_depth is only working in GMS2.
And could you explain it a little bit more?Sorry but i'm a beginner,and i'm trying to understand these things.
 
D

dannyjenn

Guest
An array is just a list of variables. Without arrays, you'd need separate variables for everything. But with an array, you just need the one array with separate indices.

Arrays have nothing to do with the interface, though they can make it easier to organize the interface, because array indices can easily be mapped to visual coordinates, and because looping through an array is a lot less confusing than trying to deal with a whole bunch of separate variables.
 
D

dannyjenn

Guest
For what you're doing, I would make a new object called obj_cells, which will be your three cells. You start by putting some code like this into its create event:
Code:
// in obj_cells's create event:
cells[0] = noone;
cells[1] = noone;
cells[2] = noone;
number_of_cells = 3;
That code sets up the array. noone is a built-in constant which just means that the cell is empty.

As for adding the correct object to each cell when the player clicks it in the skills panel, that really depends on how you have your skills panel set up.
 

Zhanghua

Member
I think what dannyjenn said is distinct, and you should learn more GML Syntax and try some little easy tutorial following the youtube vedio.
And I couldn't explain much detailedly except I code a new project.
I guess..... Good luck.
 
B

Barack Pálinka

Guest
I think what dannyjenn said is distinct, and you should learn more GML Syntax and try some little easy tutorial following the youtube vedio.
And I couldn't explain much detailedly except I code a new project.
I guess..... Good luck.
Thank you!
 
Top