ER
2016-08-23 03:45:47 UTC
Hi,
For a game I've been trying to figure how to make it shoot but haven't
been able to wrap my mind around it
I want it were I press a button, i.e command button, and the weapon
should fly off in what ever
direction the character is facing. Also I would like it so that if
the button is held down it doesn't keep firing,
it needs to be pressed again.
Right now I have this
(Weapon is an instance of WeaponClass. )
UpdatePlayer(g as graphics)
.
.
.
if Keyboard.AsyncCommandKey then
AddWeapon
Weapon.shoot
g.DrawPicture(Weapon.GetImage(Weapon.MyDirection),Weapon.x,Weapon.y)
end if
AddWeapon()
Weapon = New WeaponClass
Weapon.images.append knife_up
Weapon.images.append knife_down
Weapon.images.append knife_left
Weapon.images.append knife_right
// set weapon x/y to hero's x/y
Weapon.x = HeroObject.x
Weapon.y = HeroObject.y
//set Weapon direction to whatever direction hero is facing.
Weapon.MyDirection = HeroObject.MyDirection
Weapon
shoot()
Select case MyDirection
case "left"
x = (x+12)
case "right"
X = (x -12)
case "up"
y = (y -12)
case "down"
y = (y + 12)
end Select
_______________________________________________
Unsubscribe by sending a message to:
<nug-***@lists.xojo.com>
List Help: <***@xojo.com>
For a game I've been trying to figure how to make it shoot but haven't
been able to wrap my mind around it
I want it were I press a button, i.e command button, and the weapon
should fly off in what ever
direction the character is facing. Also I would like it so that if
the button is held down it doesn't keep firing,
it needs to be pressed again.
Right now I have this
(Weapon is an instance of WeaponClass. )
UpdatePlayer(g as graphics)
.
.
.
if Keyboard.AsyncCommandKey then
AddWeapon
Weapon.shoot
g.DrawPicture(Weapon.GetImage(Weapon.MyDirection),Weapon.x,Weapon.y)
end if
AddWeapon()
Weapon = New WeaponClass
Weapon.images.append knife_up
Weapon.images.append knife_down
Weapon.images.append knife_left
Weapon.images.append knife_right
// set weapon x/y to hero's x/y
Weapon.x = HeroObject.x
Weapon.y = HeroObject.y
//set Weapon direction to whatever direction hero is facing.
Weapon.MyDirection = HeroObject.MyDirection
Weapon
shoot()
Select case MyDirection
case "left"
x = (x+12)
case "right"
X = (x -12)
case "up"
y = (y -12)
case "down"
y = (y + 12)
end Select
_______________________________________________
Unsubscribe by sending a message to:
<nug-***@lists.xojo.com>
List Help: <***@xojo.com>