Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Field last_enemy_time:Float
- Field next_enemy_interval:Float
- ' create named collision groups
- Const PLAYER_GROUP:Int = 1
- Const ENEMY_GROUP:Int = 2
- Method OnCreate()
- Self.engine = New ftEngine
- default_scene = engine.GetDefaultScene()
- default_layer = engine.GetDefaultLayer()
- Local box:ftObject = Self.engine.CreateBox(120, 20, engine.GetCanvasWidth()/2, engine.GetCanvasHeight()/2)
- box.SetColor(0, 70, 70)
- box.SetMaxSpeed(20.0)
- box.SetMinSpeed(-20.0)
- ' Set the collision group the player character is part of
- ' and the collsion type
- box.SetColGroup(PLAYER_GROUP)
- box.SetColType(Self.engine.ctBox)
- Self.player = New Character(box, True)
- Self.enemies = New List<Character>()
- Self.last_enemy_time = Millisecs()
- Self.next_enemy_interval = 3000
- Seed = Millisecs()
- End
- ' .....................
- Method CreateEnemy()
- Local rand_width:Float = Rnd(3, 7) * 10
- Local rand_height:Float = Rnd(3, 7) * 10
- Local rand_y:Float = Rnd(rand_height, Self.engine.GetCanvasHeight())
- Local box:ftObject = Self.engine.CreateBox(rand_width, rand_height, Self.engine.GetCanvasWidth(), rand_y)
- Local rand_color:Float = Rnd(0, 3)
- Local colors:Int[] = [0, 0, 0]
- If (rand_color <= 1.0)
- colors = [255, 0, 0]
- Else If (rand_color > 1.0 And rand_color <= 2.0)
- colors = [0, 255, 0]
- Else
- colors = [0, 255, 0]
- End
- box.SetColor(colors[0], colors[1], colors[2])
- box.SetSpeedX(Rnd(10, 30) * -1)
- ' We add the enemy box to the enemy collision group
- ' and make it able to collide with the player
- box.SetColGroup(ENEMY_GROUP)
- box.SetColWith(PLAYER_GROUP, True)
- enemies.AddLast(New Character(box))
- Self.next_enemy_interval = Rnd(0, 3) * 1000
- End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement