214 lines
5.2 KiB
C++
214 lines
5.2 KiB
C++
|
|
||
|
#include "GUI.hpp"
|
||
|
|
||
|
extern "C"
|
||
|
{
|
||
|
#include <math.h>
|
||
|
}
|
||
|
|
||
|
void Script_GUI::Start()
|
||
|
{
|
||
|
|
||
|
vie = 6;
|
||
|
restart = 4;
|
||
|
score = 0;
|
||
|
|
||
|
}
|
||
|
|
||
|
void Script_GUI::Update()
|
||
|
{
|
||
|
ML_rectangle(0,57,127,63,1,ML_WHITE,ML_WHITE);
|
||
|
|
||
|
const unsigned char SVie[]={0x77, 0x8f, 0x8f, 0x77, };
|
||
|
const unsigned char Keby[]={0x3e, 0x0, 0x41, 0x11, 0x80, 0x8a, 0xa4, 0x84, 0xa4, 0x8a, 0x41, 0x51, 0xff, 0xc0, };
|
||
|
|
||
|
int position;
|
||
|
|
||
|
if(score >99999) position = 12;
|
||
|
else if(score >9999) position = 16;
|
||
|
else if(score >999) position = 20;
|
||
|
else if(score >99) position = 24;
|
||
|
else if(score >9) position = 28;
|
||
|
else position = 32;
|
||
|
|
||
|
PrintMini(1,58,"Sc:",0);
|
||
|
PrintV(position,58,score);
|
||
|
|
||
|
PrintMini(39,58,"Kirby",0);
|
||
|
|
||
|
if(vie > 0)ML_bmp_or(SVie , 62 , 59 , 5 , 4);
|
||
|
if(vie > 1)ML_bmp_or(SVie , 68 , 59 , 5 , 4);
|
||
|
if(vie > 2)ML_bmp_or(SVie , 74 , 59 , 5 , 4);
|
||
|
if(vie > 3)ML_bmp_or(SVie , 80 , 59 , 5 , 4);
|
||
|
if(vie > 4)ML_bmp_or(SVie , 86 , 59 , 5 , 4);
|
||
|
if(vie > 5)ML_bmp_or(SVie , 92 , 59 , 5 , 4);
|
||
|
|
||
|
if(vie < 1)ML_rectangle(63,60,65,61, 1 , ML_BLACK , ML_BLACK);
|
||
|
if(vie < 2)ML_rectangle(69,60,71,61, 1 , ML_BLACK , ML_BLACK);
|
||
|
if(vie < 3)ML_rectangle(75,60,77,61, 1 , ML_BLACK , ML_BLACK);
|
||
|
if(vie < 4)ML_rectangle(81,60,83,61, 1 , ML_BLACK , ML_BLACK);
|
||
|
if(vie < 5)ML_rectangle(87,60,89,61, 1 , ML_BLACK , ML_BLACK);
|
||
|
if(vie < 6)ML_rectangle(93,60,95,61, 1 , ML_BLACK , ML_BLACK);
|
||
|
|
||
|
|
||
|
ML_bmp_or(Keby , 102 , 57 , 16 , 7);
|
||
|
|
||
|
PrintV(122 , 58 , restart);
|
||
|
|
||
|
if(input_press(K_EXIT))GetEngine()->StopGame();
|
||
|
if(input_press(K_ALPHA))GetEngine()->ShowFps();
|
||
|
}
|
||
|
|
||
|
|
||
|
void Script_GUI::DelVie(int v)
|
||
|
{
|
||
|
vie -= v;
|
||
|
|
||
|
if(vie <= 0)
|
||
|
{
|
||
|
Lose();
|
||
|
vie = 6;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void Script_GUI::AddScore(int v)
|
||
|
{
|
||
|
if(v > 0)score += v;
|
||
|
}
|
||
|
|
||
|
void Script_GUI::Lose()
|
||
|
{
|
||
|
bool cinematic = true;
|
||
|
|
||
|
int y = GetEngine()->ListeObject[0]->OTransforms->GetY();
|
||
|
|
||
|
float force = 4.5;
|
||
|
|
||
|
GetEngine()->ListeObject[0]->ORender->SetIt(11);
|
||
|
|
||
|
ML_clear_vram();
|
||
|
|
||
|
GetEngine()->gamemap->AfficherMap();
|
||
|
GetEngine()->ListeObject[0]->OTransforms->SetY(y);
|
||
|
GetEngine()->UpdateRelativePosition();
|
||
|
GetEngine()->ListeObject[0]->ORender->DrawObject();
|
||
|
this->Update();
|
||
|
|
||
|
ML_display_vram();
|
||
|
|
||
|
Sleep(400);
|
||
|
|
||
|
while(cinematic == true)
|
||
|
{
|
||
|
|
||
|
y += force;
|
||
|
force -= 0.25;
|
||
|
|
||
|
ML_clear_vram();
|
||
|
|
||
|
if(y < -16) cinematic = false;
|
||
|
|
||
|
GetEngine()->gamemap->AfficherMap();
|
||
|
|
||
|
GetEngine()->ListeObject[0]->OTransforms->SetY(y);
|
||
|
|
||
|
GetEngine()->UpdateRelativePosition();
|
||
|
|
||
|
GetEngine()->ListeObject[0]->ORender->DrawObject();
|
||
|
this->Update();
|
||
|
|
||
|
ML_display_vram();
|
||
|
|
||
|
Sleep(25);
|
||
|
}
|
||
|
|
||
|
restart --;
|
||
|
|
||
|
if(restart <= 0)
|
||
|
{
|
||
|
TryAgain();
|
||
|
}
|
||
|
|
||
|
GetEngine()->ListeObject[0]->OTransforms->SetXY(0, 17);
|
||
|
}
|
||
|
|
||
|
void Script_GUI::TryAgain()
|
||
|
{
|
||
|
bool end = false;
|
||
|
int choix = 0;
|
||
|
|
||
|
float b;
|
||
|
|
||
|
const unsigned char Pointeur[]={0x3, 0x80, 0x1f, 0x4, 0x40, 0x1f, 0x4, 0x40, 0x1f, 0x8, 0x80, 0x1f, 0x30, 0xff, 0xdf, 0x40, 0x0, 0x3f, 0x81, 0xf0, 0x3f, 0x82, 0xf, 0xdf, 0x82, 0x8, 0x1f, 0x82, 0x8, 0x1f, 0x41, 0xf0, 0x1f, 0x42, 0x8, 0x1f, 0x3a, 0x8, 0x1f, 0x1, 0xf0, 0x1f, };
|
||
|
|
||
|
const unsigned char Bulle[]={0x30, 0x3f, 0x48, 0x3f, 0x84, 0x3f, 0x84, 0x3f, 0x48, 0x3f, 0x30, 0x3f, 0x0, 0x3f, 0x1, 0xbf, 0x2, 0x7f, 0x2, 0x7f, 0x1, 0xbf, };
|
||
|
const unsigned char KS1[]={0x3, 0xe0, 0x7f, 0xc, 0x18, 0x7f, 0x10, 0x4, 0x7f, 0x20, 0x2, 0x7f, 0x20, 0x2, 0x7f, 0x40, 0x1, 0x7f, 0x44, 0x61, 0x7f, 0x42, 0x81, 0x7f, 0xc0, 0x3, 0x7f, 0xa1, 0x4, 0xff, 0x91, 0x8, 0xff, 0x88, 0x10, 0xff, 0x85, 0x31, 0x7f, 0x7a, 0xde, 0x7f, };
|
||
|
const unsigned char KS2[]={0x0, 0x0, 0x7f, 0x3, 0xe0, 0x7f, 0xc, 0x18, 0x7f, 0x10, 0x4, 0x7f, 0x20, 0x2, 0x7f, 0x20, 0x2, 0x7f, 0x40, 0x1, 0x7f, 0x44, 0x61, 0x7f, 0x42, 0x83, 0x7f, 0xa0, 0x4, 0xff, 0x91, 0x8, 0xff, 0x88, 0x10, 0xff, 0x8c, 0x31, 0x7f, 0x77, 0xde, 0x7f, };
|
||
|
|
||
|
Sprite S_Kirby_Sleep1(KS1, 17 , 14 );
|
||
|
Sprite S_Kirby_Sleep2(KS2, 17 , 14 );
|
||
|
|
||
|
Sprite S_Kirby_Sleep[]={ S_Kirby_Sleep1 , S_Kirby_Sleep2};
|
||
|
|
||
|
Animation A_Sleep(S_Kirby_Sleep , 2 , 750);
|
||
|
|
||
|
ML_clear_vram();
|
||
|
PrintXY(35,25,"GAME OVER",0);
|
||
|
ML_display_vram();
|
||
|
|
||
|
Sleep(1500);
|
||
|
|
||
|
b = -15;
|
||
|
|
||
|
while(end == false)
|
||
|
{
|
||
|
ML_clear_vram();
|
||
|
|
||
|
input_update();
|
||
|
|
||
|
PrintXY( 20 , 5 , "Kirby's DreamLand" , 0);
|
||
|
PrintXY( 35 , 25 , "Continue" , 0);
|
||
|
PrintXY( 35 , 35 , "End" , 0);
|
||
|
|
||
|
A_Sleep.DrawAnim( 95 , 45 , 0);
|
||
|
if( b > 0) ML_bmp_or( Bulle , 90 - b , 44 - b , 10 ,11 );
|
||
|
|
||
|
b += 0.1; if( b > 10) b = -15;
|
||
|
|
||
|
|
||
|
if(input_any_key())
|
||
|
{
|
||
|
if(input_trigger(K_DOWN))choix ++;
|
||
|
if(input_trigger(K_UP))choix --;
|
||
|
|
||
|
if(choix < 0)choix = 0;
|
||
|
if(choix > 1)choix = 1;
|
||
|
|
||
|
if(input_trigger(K_EXE))end = true;
|
||
|
}
|
||
|
|
||
|
switch(choix)
|
||
|
{
|
||
|
case 0: ML_bmp_or(Pointeur , 8 , 22 , 19 , 14); break;
|
||
|
case 1: ML_bmp_or(Pointeur , 8 , 32 , 19 , 14); break;
|
||
|
}
|
||
|
|
||
|
|
||
|
ML_display_vram();
|
||
|
|
||
|
Sleep(10);
|
||
|
}
|
||
|
|
||
|
if(choix == 0)
|
||
|
{
|
||
|
this->restart = 4;
|
||
|
score = score / 2 ;
|
||
|
}
|
||
|
|
||
|
if(choix == 1)
|
||
|
{
|
||
|
GetEngine()->StopGame();
|
||
|
}
|
||
|
|
||
|
}
|