Hello,
I'm trying to learn how to programing in Fenix. I start a dice game : "yam's".
I think the code is a bit clumsy but it almost works as I want. I had a look in differents tutorials and game codes but I still have basics problems...
I try differents ways to exit the program but nothing works...
What do you advice to quit correctly the game?
In future developments, i would like to click on dices to keep them from the next draw.
Does the way i code the dices allow to check for a collision with the mouse pointer?
I post the code right here:
CODE
//------------------------------------------------------------------------------
// Yam version 0.1 30-01-2009
//------------------------------------------------------------------------------
Program yam;
global
//GP2X Keys
__A = _control;
__B = _alt;
__X = _x;
__Y = _y;
__SELECT = _space;
__R = _tab;
__L = _backspace;
__START = _enter;
//__VolP = _à définir;
//__VolM = _à définir;
//Loading stuff
hasard1;
map1;
hasard2;
map2;
hasard3;
Map3;
hasard4;
map4;
hasard5;
map5;
//Sprites & Fonts
fpg1;
fnt1;
//Counter
num_de;
begin
//Initialisation de l'écran
set_mode(320,240,16);
set_fps(30,0);
//Chargement des graphics
fpg1 = load_fpg("yam16bit.fpg");
fnt1 = load_fnt("big.fnt");
set_text_color(1);
//title
nettoyage_ecran ();
Loop;
//Exit if pressed escape
if(key(_esc))exit();end
While (!key(__B));
//Clean the screen
nettoyage_ecran ();
From num_de = 1 to 5 step 1
//Draw randomly 5 dices
dice(num_de);
End;
FRAME(250);
End;
display_dice ();
Repeat
FRAME;
Until (key(__A));
nettoyage_ecran ();
End;
End;
///////////////////////////////////////////////////////////////////////////////////////////////////
//PROCESSES
///////////////////////////////////////////////////////////////////////////////////////////////////
Process dice (Int number)
//Draw randomly 5 dices
Private
num_dice;
begin
num_dice = rand (1,6);
put(fpg1, num_dice, (40*number), 210);
if (number == 1)
hasard1 = num_dice;
End;
if (number == 2)
hasard2 = num_dice;
End;
if (number == 3)
hasard3 = num_dice;
End;
if (number == 4)
hasard4 = num_dice;
End;
if (number == 5)
hasard5 = num_dice;
End;
End;
///////////////////////////////////////////////////////////////////////////////////////////////////
Process display_dice ()
//Display the result
begin
write ( 0, 100, 80, 1, "Dice n°1 : " + hasard1);
write ( 0, 100, 90, 1, "Dice n°2 : " + hasard2);
write ( 0, 100, 100, 1, "Dice n°3 : " + hasard3);
write ( 0, 100, 110, 1, "Dice n°4 : " + hasard4);
write ( 0, 100, 120, 1, "Dice n°5 : " + hasard5);
write ( 0, 220, 90, 1, "A new draw?");
write ( 0, 220, 110, 1, "Press Ctrl");
End;
///////////////////////////////////////////////////////////////////////////////////////////////////
Process nettoyage_ecran ()
//Clean the screen and display the title
begin
delete_text(all_text);
PUT_SCREEN ( fpg1,7);
write ( 1, 160, 15, 1, "YAM'S par D&G");
Frame;
End;
the missing files are here:
SOURCES & FPG
I really appreciate any help or advice!!
Thanks in advance!
Guzzo
I'm trying to learn how to programing in Fenix. I start a dice game : "yam's".
I think the code is a bit clumsy but it almost works as I want. I had a look in differents tutorials and game codes but I still have basics problems...
I try differents ways to exit the program but nothing works...
What do you advice to quit correctly the game?
In future developments, i would like to click on dices to keep them from the next draw.
Does the way i code the dices allow to check for a collision with the mouse pointer?
I post the code right here:
CODE
//------------------------------------------------------------------------------
// Yam version 0.1 30-01-2009
//------------------------------------------------------------------------------
Program yam;
global
//GP2X Keys
__A = _control;
__B = _alt;
__X = _x;
__Y = _y;
__SELECT = _space;
__R = _tab;
__L = _backspace;
__START = _enter;
//__VolP = _à définir;
//__VolM = _à définir;
//Loading stuff
hasard1;
map1;
hasard2;
map2;
hasard3;
Map3;
hasard4;
map4;
hasard5;
map5;
//Sprites & Fonts
fpg1;
fnt1;
//Counter
num_de;
begin
//Initialisation de l'écran
set_mode(320,240,16);
set_fps(30,0);
//Chargement des graphics
fpg1 = load_fpg("yam16bit.fpg");
fnt1 = load_fnt("big.fnt");
set_text_color(1);
//title
nettoyage_ecran ();
Loop;
//Exit if pressed escape
if(key(_esc))exit();end
While (!key(__B));
//Clean the screen
nettoyage_ecran ();
From num_de = 1 to 5 step 1
//Draw randomly 5 dices
dice(num_de);
End;
FRAME(250);
End;
display_dice ();
Repeat
FRAME;
Until (key(__A));
nettoyage_ecran ();
End;
End;
///////////////////////////////////////////////////////////////////////////////////////////////////
//PROCESSES
///////////////////////////////////////////////////////////////////////////////////////////////////
Process dice (Int number)
//Draw randomly 5 dices
Private
num_dice;
begin
num_dice = rand (1,6);
put(fpg1, num_dice, (40*number), 210);
if (number == 1)
hasard1 = num_dice;
End;
if (number == 2)
hasard2 = num_dice;
End;
if (number == 3)
hasard3 = num_dice;
End;
if (number == 4)
hasard4 = num_dice;
End;
if (number == 5)
hasard5 = num_dice;
End;
End;
///////////////////////////////////////////////////////////////////////////////////////////////////
Process display_dice ()
//Display the result
begin
write ( 0, 100, 80, 1, "Dice n°1 : " + hasard1);
write ( 0, 100, 90, 1, "Dice n°2 : " + hasard2);
write ( 0, 100, 100, 1, "Dice n°3 : " + hasard3);
write ( 0, 100, 110, 1, "Dice n°4 : " + hasard4);
write ( 0, 100, 120, 1, "Dice n°5 : " + hasard5);
write ( 0, 220, 90, 1, "A new draw?");
write ( 0, 220, 110, 1, "Press Ctrl");
End;
///////////////////////////////////////////////////////////////////////////////////////////////////
Process nettoyage_ecran ()
//Clean the screen and display the title
begin
delete_text(all_text);
PUT_SCREEN ( fpg1,7);
write ( 1, 160, 15, 1, "YAM'S par D&G");
Frame;
End;
the missing files are here:
SOURCES & FPG
I really appreciate any help or advice!!
Thanks in advance!
Guzzo