if self.y < 0 then
self.y = 0
self.vy = 0
- else if self.y > 60000 then
- self.y = 60000
+ else if self.y > scene.height then
+ self.y = scene.height
self.vy = 0
end
if self.x < 0 then
self.x = 0
self.vx = 0
- else if self.x > 80000 then
- self.x = 80000
+ else if self.x > scene.width then
+ self.x = scene.width
self.vx = 0
end
else
shoot_ttl = 30
for i in [0..nbshoots[ do
- var shoot = new Shoot
+ var shoot = new Shoot(scene)
shoot.x = x
shoot.y = top
shoot.vy = -500
missile_ttl -= 1
else if nbmissiles > 0 then
missile_ttl = 500 / nbmissiles
- var shoot = new Missile
+ var shoot = new Missile(scene)
shoot.x = x
shoot.y = top
shoot.vy = -300
self.exists = false
# Reset the position for respawn
- self.x = 400 * 100
- self.y = 500 * 100
+ self.x = scene.width / 2
+ self.y = scene.height - 10000
self.vx = 0
self.vy = 0
self.respawn_ttl = 50
# Since there is no frendly fire, it is important to distinguish ownership
var enemy: Bool = false
- init do
+ # The scene of the sprite
+ # Is used with bound limits
+ var scene: PlayScene
+
+ init(scene: PlayScene)
+ do
+ self.scene = scene
self.width = 800
self.height = 800
end
super
# Out of screen ?
- if self.y < -100 * 100 or self.y > 700 * 100 or self.x < -100 * 100 or self.x > 900 * 100 then
+ if self.y < -100 * 100 or self.y > scene.height + 10000 or self.x < -100 * 100 or self.x > scene.width + 10000 then
self.exists = false
end
end
super
# Out of screen ?
- if self.y > 700 * 100 or self.x < -100 * 100 or self.x > 900 * 100 then
+ if self.y > scene.height + 10000 or self.x < -100 * 100 or self.x > scene.width + 10000 then
# Note: no control on the top to let ennemies appear
self.exists = false
end
self.exists = false
scene.explosion(self.x, self.y, 5)
if 100.rand < 3 then
- var upmissile = new UpMissile
+ var upmissile = new UpMissile(scene)
upmissile.x = self.x
upmissile.y = self.y
upmissile.vx = 0
scene.hitables.add(new LootArea(upmissile, 2000))
else
for i in [0..self.loot[ do
- var money = new Money
+ var money = new Money(scene)
money.x = self.x
money.y = self.y
money.set_velocity(100.rand.to_f*pi/50.0, (500+self.loot).rand)
# two bullets shoot each time
for dx in [-11, 11] do
- var shoot = new Shoot
+ var shoot = new Shoot(scene)
shoot.enemy = true
shoot.x = self.x + dx * 100
shoot.y = self.bottom
shoot_ttl = 200
# The missile targets the player
- var shoot = new Missile
+ var shoot = new Missile(scene)
shoot.enemy = true
shoot.x = self.x
shoot.y = self.bottom
shoot_ttl = 50
for i in [0..10[ do
- var shoot = new Shoot
+ var shoot = new Shoot(scene)
shoot.enemy = true
shoot.x = self.x
shoot.y = self.bottom
end
# Shoot with the turret angle
- var shoot = new Shoot
+ var shoot = new Shoot(scene)
shoot.enemy = true
shoot.x = self.x
shoot.y = self.y
super
self.width = 128 * 100
self.height = 100 * 100
- self.x = 400 * 100
+ self.x = scene.width / 2
self.y = -100 * 100
self.left_part = new BossPart(self, -48*100)
self.right_part = new BossPart(self, 48*100)
else if self.vx == 0 then
self.vx = 100
self.vy = 0
- else if self.x > 700 * 100 and self.vx > 0 then
+ else if self.x > scene.width - 10000 and self.vx > 0 then
self.vx = -self.vx
- else if self.x < 100 * 100 and self.vx < 0 then
+ else if self.x < 10000 and self.vx < 0 then
self.vx = -self.vx
end
end
# Shoot the player with a basic bullet
- var shoot = new Shoot
+ var shoot = new Shoot(scene)
shoot.enemy = true
shoot.x = self.x
shoot.y = self.bottom
shoot_ttl = 600
# Shoot a missile that targets the player
- var shoot = new Missile
+ var shoot = new Missile(scene)
shoot.enemy = true
shoot.x = self.x
shoot.y = self.bottom
abstract class Loot
super Hitable
- init
+ var scene: PlayScene
+
+ init(scene: PlayScene)
do
+ self.scene = scene
self.width = 400
self.height = 400
end
super
# Out of screen ?
- if self.y > 700 * 100 then
+ if self.y > scene.height + 10000 then
self.exists = false
end
class Star
super Sprite
- init
+ # The scene of the sprite
+ # Is used with bound limits
+ var scene: ShotScene
+
+ init(scene: ShotScene)
do
+ self.scene = scene
# Randomely places stars on the plane
- self.x = 800.rand * 100
- self.y = 600.rand * 100
+ self.x = scene.width.rand
+ self.y = scene.height.rand
self.vy = 40.rand + 11
end
super
# Replace the star on the top
- if self.y > 600 * 100 then
+ if self.y > scene.height then
self.y = 200.rand * -100
- self.x = 800.rand * 100
+ self.x = scene.width.rand
self.vy = 40.rand + 11
end
end
do
super
self.player = new Player(self)
- player.x = 400 * 100
- player.y = 500 * 100
+ player.x = self.width / 2
+ player.y = self.height - 10000
self.sprites.add(background)
self.sprites.add(pasive_stuff)
self.sprites.add(loots)
self.sprites.add(hitables)
for i in [0..100[ do
- background.add(new Star)
+ background.add(new Star(self))
end
hitables.add(player.going_target)
else
enemy = new Enemy4(self)
end
- enemy.x = 600.rand * 100 + 10000
+ enemy.x = (self.width - 20000).rand + 10000
enemy.vy = 200.rand + 100
if 10.rand < 3 then
enemy.vx = 200.rand - 100
do
super
for i in [0..100[ do
- sprites.add(new Star)
+ sprites.add(new Star(self))
end
end