Page 1 of 1

controls and flashing button question

PostPosted: Thu Sep 14, 2006 9:18 am
by relaxis
Code: Select all
if (i==0)
{
transp=0;
i=1;
}
else if (i==1)
{
transp=1
i=0;
}


I was given this code in order to create a flashing button in a loop but I can't get it to work!!

I also need to create a piece of code that responds to certain controls throughout the game, it needs to be so that at any point in the game, if L and R and START are pressed all together, the game exits. I need also to incorporate some kind of volume control.

Does someone have code for a menu system that works BTW?

Can someone show me a working example of loading a DAT file?

Thanks.

Re: controls and flashing button question

PostPosted: Thu Sep 14, 2006 12:26 pm
by makslane
relaxis wrote:I was given this code in order to create a flashing button in a loop but I can't get it to work!!


If you put this code in a Draw Actor event, your actor will flash:

Code: Select all
if(transp == 1.0) transp = 0;
else if(transp == 0.0) transp = 1.0;


I also need to create a piece of code that responds to certain controls throughout the game, it needs to be so that at any point in the game, if L and R and START are pressed all together, the game exits. I need also to incorporate some kind of volume control.


You can see an exit and volume control work example here:
http://game-editor.com/examples/gp2x.zip

To exit the game when L, R and START are pressed together, just use a Key Down event, put the keys L, R and S (map the GP2X Start -> S in the Game Properties), select the option 'All keys are pressed' and put the code:

Code: Select all
ExitGame();


To use the keys + and - to control the volume, remap the volume keys in the Game Properties panel:

GP2X Volume Up -> [+]
GP2X Volume Down -> [-]

Now, in a Key Down event for the key - with repeat enable put:

Code: Select all
//Set music
musicvol -= .01;
if(musicvol < 0.0) musicvol = 0.0;

//Set all sound channels
setVolume(0, musicvol);


In a Key Down event for the key + with repeat enable put:

Code: Select all
//Set music
musicvol += .01;
if(musicvol > 1.0) musicvol = 1.0;

//Set all sound channels
setVolume(0, musicvol);


To mute the sounds, use a Key Down event for the keys - and + with repeat disable, 'All keys are pressed' option, and put:

Code: Select all
//Set music
musicvol = 0.0;

//Set all sound channels
setVolume(0, musicvol);



Can someone show me a working example of loading a DAT file?


If you have the game level2.ged to load, just use the code:

Code: Select all
LoadGame("level2.ged");


This will load the level2.dat file in the exported game and level2.ged file in the editor.

More info here:
http://www.game-editor.com/docs/script_ ... m#loadgame
http://game-editor.com/games/breakout.zip

PostPosted: Fri Sep 15, 2006 11:09 am
by relaxis
thanks, do you know how i can make something fade in and out over time?

PostPosted: Fri Sep 15, 2006 12:01 pm
by makslane
Just change the transparency in a 'Draw Actor' or Timer event:

Code: Select all
transp += .01;