keeps popping op error message on my game

Ask gaming related questions (AHK v1.1 and older)
tomaxtoro
Posts: 16
Joined: 12 Dec 2020, 07:18

keeps popping op error message on my game

Post by tomaxtoro » 28 Jul 2021, 10:58

Code: Select all

#Singleinstance,Force

 

Player:={x:200, y:200, w:20, h:20, speed:3}
Health:={x:10, y:10, w:100, h:20, HP1:100}

 

Gui,+AlwaysOnTop
Gui,color, black

 

gui,add, progress,% "x" Player.x " y" Player.y " w" Player.w " h" Player.h " cWhite BackGroundLime vPlayer_1"

 
gui,font, cWhite  s15
gui,add, edit, , %HP1%,% "x" Health.x " y" Health.y " w" Health.w " h" Health.h " cLime BackGroundRed vHealth_HP1"

 

 


Gui, show, x800 y100 w500 h500, Game

 

SetTimer,Move_player,10

 

HP1:
{
    GuiControl, ,Health.HP1, %HP1% ;Guicontrol, ,Health_Health, "amount of health"
}

 

 

return
Guiclose: 
Exitapp

 

Move_player:

 

Damage:=10

 

    if(GetKeyState("up"))
        {
            if(player.y>0)
                player.y-=player.speed
            if(player.y=20)
                Health.HP1-=Damage

 

        }

 

        if(Getkeystate("down"))
            {
                if(player.y<500-player.h)
                    player.y+=player.speed
                if(player.y=480)
                    Health.HP1-=Damage
            }

 

        if(Getkeystate("left"))
            {
                if(player.x>0)
                    player.x-=player.speed
                if(player.x=20)
                    Health.HP1-=Damage
            }

 

        if(Getkeystate("right"))
            {
                if(player.x<500-player.w)
                    player.x+=player.speed
                if(player.x=480)
                    Health.HP1-=Damage
            }

 

            if(Health.HP1=0)
                Guiclose_die:
                Exitapp

 


Guicontrol, Move,Player_1, % "x" player.x " y" player.y
Tooltip,% Health.HP1
 return
[Mod edit: [code][/code] tags added.]
Last edited by gregster on 28 Jul 2021, 13:45, edited 1 time in total.
Reason: Please use [code] tags. Thank you!
Rohwedder
Posts: 7627
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: keeps popping op error message on my game

Post by Rohwedder » 28 Jul 2021, 12:21

Hallo,
perhaps:

Code: Select all

#Singleinstance,Force
Player:={x:200, y:200, w:20, h:20, speed:3}
Health:={x:10, y:10, w:100, h:20, HP1:100}
Gui,+AlwaysOnTop
Gui,color, black
gui,add, progress,% "x" Player.x " y" Player.y " w" Player.w " h" Player.h " cWhite BackGroundLime vPlayer_1"
gui,font, cWhite s15
gui,add, edit,% Health.HP1 " x" Health.x " y" Health.y " w" Health.w " h" Health.h " cLime BackGroundRed vHealth_HP1"
Gui, show, x800 y100 w500 h500, Game
SetTimer,Move_player,10
HP1:
{
	GuiControl, ,Health.HP1, %HP1% ;Guicontrol, ,Health_Health, "amount of health"
}
return
Guiclose:
Exitapp
Move_player:
Damage:=10
if(GetKeyState("up"))
{
	if(player.y>0)
		player.y-=player.speed
	if(player.y=20)
		Health.HP1-=Damage
}
if(Getkeystate("down"))
{
	if(player.y<500-player.h)
		player.y+=player.speed
	if(player.y=480)
		Health.HP1-=Damage
}
if(Getkeystate("left"))
{
	if(player.x>0)
		player.x-=player.speed
	if(player.x=20)
		Health.HP1-=Damage
}
if(Getkeystate("right"))
{
	if(player.x<500-player.w)
		player.x+=player.speed
	if(player.x=480)
		Health.HP1-=Damage
}
if(Health.HP1=0)
	Guiclose_die:
Exitapp
Guicontrol, Move,Player_1, % "x" player.x " y" player.y
Tooltip,% Health.HP1
return
tomaxtoro
Posts: 16
Joined: 12 Dec 2020, 07:18

thanks

Post by tomaxtoro » 28 Jul 2021, 14:26

thanks alot but now i want it to show on the edit mabey you could help, and i want it to show in text on the edit
Rohwedder
Posts: 7627
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: keeps popping op error message on my game

Post by Rohwedder » 29 Jul 2021, 03:24

This?:

Code: Select all

HP1:
{
	GuiControl,% Health.HP1, %HP1%
	Guicontrol,, Health_HP1, amount of health
}
Post Reply

Return to “Gaming Help (v1)”