Created
February 3, 2017 14:55
-
-
Save codetravis/f27ed03c2d44ec0f05f4119ecea55643 to your computer and use it in GitHub Desktop.
13.4 Add projectile images from sprite sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' use our sprite atlas for projectiles | |
Method CreateProjectile(character:Character, width_modifier:Float=0, height_modifier:Float=0) | |
Local projectile_box:ftObject | |
If (character.character_type = "PLAYER") | |
projectile_box = Self.engine.CreateImage(game_sprite_atlas.GetImage("player_projectile"), | |
character.box.GetPosX() + character.box.GetWidth()/2 + width_modifier, | |
character.box.GetPosY() + height_modifier) | |
projectile_box.SetSpeedX(10) | |
projectile_box.SetColor(0, 255, 255) | |
projectile_box.SetColWith(ENEMY_GROUP, True) | |
Else | |
projectile_box = Self.engine.CreateImage(game_sprite_atlas.GetImage("enemy_projectile"), | |
character.box.GetPosX() + character.box.GetWidth()/2 + width_modifier, | |
character.box.GetPosY() + height_modifier) | |
projectile_box.SetPosX(character.box.GetPosX() - character.box.GetWidth()/2 + width_modifier) | |
projectile_box.SetSpeedX(-10) | |
projectile_box.SetColor(200, 200, 0) | |
projectile_box.SetColWith(PLAYER_GROUP, True) | |
End | |
projectile_box.SetColGroup(PROJECTILES) | |
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