I'm certainly the last person on this forum who can give advice.
But a single boolean could make the difference..
Code: ags
But a single boolean could make the difference..
bool on_ground = true;
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
bool on_ground = true;
void on_mouse_click (MouseButton button)
{
///////////////// Right Side /////////////////////
if (button == eMouseLeft && FacingRight)
{
if (mouse.x > player.x) //640x480 it's okay here
{
Fire(true, false); //right
}
}
///////////////// Left Side /////////////////////
if (button == eMouseLeft && FacingLeft)
{
if (mouse.x < player.x ) //640x480 it's okay here
{
Fire(false, true); //left
}
}
}
int time, firstcounter, secondcounter, thirdcounter, fourcounter, fivecounter, sixcounter, sevencounter, eightcounter,
ninecounter, tencounter;
bool pushed, released;
Enemy Monster[8];
function ShowTargetGUI()
{
GUIControl *theControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
gTarget.Visible = true;
if (theControl == ButtonPush && mouse.IsButtonDown(eMouseLeft) && pushed) //button pushed
{
int i = 0;
while (i<NumeriCasuali(4, 6)){ time ++; i++;}
if (time > 5) { gTarget.BackgroundGraphic = 3; firstcounter = NumeriCasuali(1, 5); }
//why if i use 'else if' doesn't work ?!
if (time > 15) { gTarget.BackgroundGraphic = 4; secondcounter = NumeriCasuali(6, 15); }
if (time > 30) { gTarget.BackgroundGraphic = 5; thirdcounter = NumeriCasuali(16, 30); }
if (time > 45) { gTarget.BackgroundGraphic = 6; fourcounter = NumeriCasuali(31, 45); }
if (time > 60) { gTarget.BackgroundGraphic = 7; fivecounter = NumeriCasuali(46, 55); }
if (time > 75) { gTarget.BackgroundGraphic = 8; sixcounter = NumeriCasuali(56, 70); }
if (time > 90) { gTarget.BackgroundGraphic = 9; sevencounter = NumeriCasuali(71, 85); }
if (time > 100) { gTarget.BackgroundGraphic = 10; eightcounter = NumeriCasuali(86, 90); }
if (time > 110) { gTarget.BackgroundGraphic = 11; ninecounter = NumeriCasuali(91, 100); }
if (time > 120) { gTarget.BackgroundGraphic = 12; tencounter = NumeriCasuali(101, 115); }
if (time > 125) // (TIME OUT) IF STILL BUTTON PUSHED
{
//Enemy RECOVER ENERGY
if (Monster[1].ID[1] == cChar.ID && Monster[1].hp < 499) Monster[1].hp += 30;
// here 'else if' is okay
else if (Monster[2].ID[2] == cChar2.ID && Monster[2].hp < 699) Monster[2].hp += 30;
else if (Monster[3].ID[3] == cChar3.ID && Monster[3].hp < 899) Monster[3].hp += 30;
else if (Monster[4].ID[4] == cChar4.ID && Monster[4].hp < 1099) Monster[4].hp += 30;
else if (Monster[5].ID[5] == cChar5.ID && Monster[5].hp < 1299) Monster[5].hp += 30;
else if (Monster[6].ID[6] == cChar6.ID && Monster[6].hp < 1499) Monster[6].hp += 30;
else if (Monster[7].ID[7] == cChar7.ID && Monster[7].hp < 2499) Monster[7].hp += 30;
pushed = false;
Labelcounter.Text = " Time's up"; //time's up
Labelhit.Text = "You Failed";
cJack.Animate(1, 2, eOnce, eNoBlock, eForwards);
gTarget.BackgroundGraphic = 2; //turn to normal graphic
time = 0;
}
SetTimer(1, 30);
}
else if (released)
{
//LOW HIT
if (time > 5)
{ cJack.Animate(1, 2, eOnce, eNoBlock, eForwards);
Labelcounter.Text = String.Format("%d %", firstcounter); Labelhit.Text = "Low Hit"; }
if (time > 15)
{ Labelcounter.Text = String.Format("%d %", secondcounter); Labelhit.Text = "Low Hit"; }
if (time > 30)
{ Labelcounter.Text = String.Format("%d %", thirdcounter); Labelhit.Text = "Low Hit"; }
//MEDIUM HIT
if (time > 45)
{ Labelcounter.Text = String.Format("%d %", fourcounter); Labelhit.Text = "Medium Hit"; }
if (time > 60)
{ Labelcounter.Text = String.Format("%d %", fivecounter); Labelhit.Text = "Medium Hit"; }
if (time > 75)
{ Labelcounter.Text = String.Format("%d %", sixcounter); Labelhit.Text = "Medium Hit"; }
//HIGH HIT
if (time > 90)
{ Labelcounter.Text = String.Format("%d %", sevencounter); Labelhit.Text = "High Hit"; }
if (time > 100)
{ Labelcounter.Text = String.Format("%d %", eightcounter); Labelhit.Text = "High Hit"; }
//super hit
if (time > 110)
{ Labelcounter.Text = String.Format("%d %", ninecounter); Labelhit.Text = "Super Hit"; }
//CRITICAL HIT
if (time > 120)
{ Labelcounter.Text = String.Format("%d %", tencounter); Labelhit.Text = "Critical Hit"; }
//TIME OUT IF BUTTON IS RELEASED
if (time > 125)
{
Labelcounter.Text = "Time Out";
Labelhit.Text = "You Failed";
gTarget.BackgroundGraphic = 2;
time = 0;
}
time = 0;
}
Labelinfo.Text = String.Format("%d", time);
}
function Battaglia()
{
countingDown=true; //check if the 'timer battle' is expired or not
if (Monster[1].ID[1] == cChar.ID)
{
if (!mouse.IsButtonDown(eMouseLeft) ) //a pseudo - released performance
{
if (gTarget.BackgroundGraphic == 3) Monster[1].hp -= firstcounter;
else if (gTarget.BackgroundGraphic == 4) Monster[1].hp -= secondcounter;
else if (gTarget.BackgroundGraphic == 5) Monster[1].hp -= thirdcounter;
else if (gTarget.BackgroundGraphic == 6) Monster[1].hp -= fourcounter;
else if (gTarget.BackgroundGraphic == 7) Monster[1].hp -= fivecounter;
else if (gTarget.BackgroundGraphic == 8) Monster[1].hp -= sixcounter;
else if (gTarget.BackgroundGraphic == 9) Monster[1].hp -= sevencounter;
else if (gTarget.BackgroundGraphic == 10) Monster[1].hp -= eightcounter;
else if (gTarget.BackgroundGraphic == 11) Monster[1].hp -= ninecounter;
else if (gTarget.BackgroundGraphic == 12) Monster[1].hp -= tencounter;
else if (ButtonExtra.NormalGraphic == 68) TEMPO -= 5; //else if 'button failed' is visible >>> timer battle go down -5
}
}
function room_RepExec()
{
if (InitBattle ) //boolean go true by click a button, boolean go false by hp enemy <= 0
{ ShowTargetGUI(); Battaglia(); }
}
void on_event (EventType event, int data)
{
GUIControl*gc = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
Button*b;
if (gc != null) b = gc.AsButton;
if (event == eEventEnterRoomBeforeFadein)
{ mouse.Visible = false; Labelcounter.Text = ""; Labelhit.Text = ""; b = ButtonPush; }
////////////// PUSHED BUTTON /////////////////////////////////////////
else if (event == eEventGUIMouseDown && b != null )
{
//Display("pushed");
pushed = true;
Labelcounter.Text = "";
ButtonExtra.Visible = false;
//ButtonExtra.X = 12;
Labelhit.Text = "";
released = false;
}
////////////// RELEASED BUTTON //////////////////////////////////////
else if (event == eEventGUIMouseUp && b != null )
{
//Display("REL");
SetTimer(1, 30);
pushed = false;
released = true;
gTarget.BackgroundGraphic = 2;
}
}
float RandomFloat(float min, float max)
{
if (min == max) return min; // same value, only one possible result
if (min > max) return RandomFloat(max, min); // min and max reversed, swap them out
return (min + Random(FloatToInt(max)-FloatToInt(min))); //type mismatch: cannot convert 'float' to 'int'
}
bool pushed, released;
int time, firstcounter;
function room_RepExec()
{
if (time > 5) { gTarget.BackgroundGraphic = 3; firstcounter = NumeriCasuali(1, 5); }
else if (released && time > 120)
{
firstcounter = 0; // Why The Hell... !!?
Labelcounter.Text = "Time Out";
Labelhit.Text = "You Failed";
gTarget.BackgroundGraphic = 2;
time = 0;
}
Labelinfo.Text = String.Format("%d %", time);
time ++;
}
function NumeriCasuali(int minimo, int massimo) //int min, int max
{
return (minimo + Random(massimo - minimo)); //wrong
}
Quote
GlobalScript.asc(221): Error (line 221): Nested functions not supported (you may have forgotten a closing brace)
function on_mouse_click(MouseButton button) {
// called when a mouse button is clicked. button is either LEFT or RIGHT
if (IsGamePaused() == 1) {
// Game is paused, so do nothing (ie. don't allow mouse click)
}
}
Quote
thanks very much Vicent!
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.044 seconds with 14 queries.