Thursday, April 9, 2015

[Progress] Designing the dungeon - part 3

So in today's GIF, you'll see I reset the room once midway. This was to show that the pressure plates will only trigger the spawning of obj_key when both of the plates are pressed simultaneously. I'm aware at the end of the picture the player steps into the void, that'll be addressed immediately. Also ignore that ugly green rectangle with the word "PICKS" in it. That is just an unfinished side project for reincorporating the UI into a HUD rather than an inventory window..

I had been stuck with figuring out how to design my pressure plates to work properly for the past three days with no luck. After bouncing around ways to approach a solution with a few people, and learning a *lot* more about handling object creation and management.

Normally when designing with the room editor, I would "hard place" the objects onto the room via clicking and placing it. Later it turns out that doing it that way can make it harder to identify certain objects as well as generating an identifier that I, personally had not been able to utilize. Instead, I created a room with just the tiles instead, and had the objects within the room placed down via creation code called upon another object (obj_dungeon_1 in this case).

Create Event

switch1 = instance_create(6*16, 1*16, obj_pressure_plate);
switch2 = instance_create(8*16, 2*16, obj_pressure_plate);

instance_create(4*16, 1*16, obj_boulder);
instance_create(7*16, 4*16, obj_boulder);

key_spawned = false;

Step Event

if (key_spawned = false && switch1.pressed && switch2.pressed) {
     key_spawned = true;
     instance_create(6*16,2*16, obj_key);

     //instance_destroy(obj_pressure_plate);
    }

Doing this, gives me explicit control of where the objects will be, what their names will be, and any arguments between specific [duplicated] objects! This was the problem I was having with my pressure plates in the first place! Differentiating the obj_pressure_plate from each other!

Now it is [almost] safe to say the framework is just about done. Pressure plates will behave similarly to traps so the foundation for that is already done. My inventory array is already handling adding/removing items in the inventory, and adding currency will just be another element into the array.

Speaking of arrays, it was a topic I brought up when talking about how to better understand them. For the longest time I was pretty sure I was using 1-dimensional arrays. After she had explained to me the differences between the dimensions, I realized I had been inadvertently using 2-dimensional arrays [correctly], which was a huge relief on my end. She pointed me towards a couple websites for supplementary reading to further my understanding:

The reading gave me a better understanding of how to handle my grid movement code, allowing me to improve it further! I am grateful to have friends and other people who can be a bountiful source of information and a deep repository of programming resources. Even more, for them not doing it for me, but just pointing me in the right direction and letting me figure it out on my own.

No comments:

Post a Comment