Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
11.6 Update constructors in the Game class and the projectile firing check
Method CreatePlayer()
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)
box.SetColGroup(PLAYER_GROUP)
box.SetColType(Self.engine.ctBox)
box.SetText("PLAYER")
Local projectile_type:ProjectileType = New ProjectileType()
' Update the constructor to use the new string identifier
Self.player = New Character(box, projectile_type, 0, 3, "PLAYER")
End
Method CreateFinalBoss()
Local box:ftObject = Self.engine.CreateBox(120, 200, engine.GetCanvasWidth() - 10, engine.GetCanvasHeight()/2)
box.SetColor(255, 0, 255)
box.SetMaxSpeed(20.0)
box.SetMinSpeed(-20.0)
box.SetColGroup(ENEMY_GROUP)
box.SetColWith(PLAYER_GROUP, True)
box.SetText("FINALBOSS")
Local projectile_type:ProjectileType = New ProjectileType(1, 1000, 1, 10, 1.5)
' Update the constructor to use the new string identifier
Self.final_boss = New Character(box, projectile_type, 500, 10, "FINALBOSS")
End
' .................
Method CreateProjectile(character:Character)
Local projectile_box:ftObject = Self.engine.CreateBox(20, 10, character.box.GetPosX() + character.box.GetWidth()/2, character.box.GetPosY())
projectile_box.SetColGroup(PROJECTILES)
' Updated this check to use the string identifier instead of the old boolean
If (character.character_type = "PLAYER")
projectile_box.SetSpeedX(50)
projectile_box.SetColor(0, 255, 255)
projectile_box.SetColWith(ENEMY_GROUP, True)
Else
projectile_box.SetPosX(character.box.GetPosX() - character.box.GetWidth()/2)
projectile_box.SetSpeedX(-50)
projectile_box.SetColor(255, 255, 0)
projectile_box.SetColWith(PLAYER_GROUP, True)
End
projectile_box.SetText("PROJECTILE")
Self.projectiles.AddLast(New Projectile(projectile_box, character.projectile_type))
End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment