Jump to content


user_4574

Member Since 13 Jun 2012
Offline Last Active May 10 2013 09:06 PM

Topics I've Started

Refining Code

13 August 2012 - 09:10 PM

I was wondering if anyone could help me refine some code I have...?

The code works well enough, but I can't help but think that there is a  more refined / easier way to achieve the same result (changing the  sprite over when the timer reaches zero, for all the objects in the  room).
Any help is appreciated.

I have tried to use a FOR loop and REPEAT, but I couldn't quite get it to the same stage. I'm not even sure if that's the right approach.


Here is the sample of code I have:


if room == Level1
{
     with Num1
     {
         if StopWatch_and_Countdown.time_left = 0
         {
         sprite_index = spr_Leaf_Cover;
         draw_sprite_ext(spr_Leaf_Cover,-1,x,y,0.45,0.45,8,- 1,1);
         }  
         else
         {
         sprite_index = spr_Num1;
         draw_sprite_ext(spr_Num1,-1,x,y,0.45,0.45,8,-1,1);
     }
     }
     with Num2
     {
         if StopWatch_and_Countdown.time_left = 0
         {
         sprite_index = spr_Leaf_Cover;
         draw_sprite_ext(spr_Leaf_Cover,-1,x,y,0.4,0.4,320,- 1,1);
         }  
         else
         {
         sprite_index = spr_Num2;
         draw_sprite_ext(spr_Num2,-1,x,y,0.4,0.4,350,-1,1);
     }
     }
     with Num3
     {
         if StopWatch_and_Countdown.time_left = 0
         {
         sprite_index = spr_Leaf_Cover;
         draw_sprite_ext(spr_Leaf_Cover,-1,x,y,0.4,0.4,330,- 1,1);
         }  
         else
         {
         sprite_index = spr_Num3;
         draw_sprite_ext(spr_Num3,-1,x,y,0.4,0.4,345,-1,1);
     }
     }
    
}


Now, As I progress through the levels, there will be more 'Num' objects  in the room (Num1, Num2, Num3 etc)... So Is there a way to assign all  the objects with the prefix "Num" their corresponding Sprite to change  to?  ie:  'Num1' (the object) will get the sprite 'spr_Num1' and so  on....without defining each and every one of them?
When they change,  they will all use the same 'spr_Leaf_Cover' sprite, so that's not an  issue.

I hope this is clear enough.

I just don't want to have to get to Level15 for example, and have 30 different  'With Num ** ' statements to define/change.

Thanks.

Room/Level Score Saving

31 July 2012 - 11:26 AM

Hi,

As a relatively new user of Game Maker Studio + Android module, I would like to know how I can go about the following:

I have a variable called 'RoomTimeScore' which pauses the time the level was running for once the final object is destroyed. All good.

How can I go about coding or using the drag/drop functions to save this value out for each room basis, ala Angry Birds style? My hope is that I don't need a different variable per-room to save this out.

What I want to achieve is on Android, the user would complete a room as fast as they can - The Room Time gets saved out and the user continues to the next level, also recording how long it took for that level without overwriting the previous room time. Then when the user comes to play the game again, I'd like to be able to read from the file which was saved, to load an overlay display of how long it took the user to complete each room they have tried on a type of menu layout - again, ala Angry Birds. It would also be helpful if when re-entering a room to replay the level, the user could see the display of their previous Room Time in an effort to beat it.

Any help would be greatly appreciated. I hope this is clear enough.

If someone can provide an example code/guide of how I can do this that would be great.