Skip to content

Instantly share code, notes, and snippets.

@codetravis
Created February 3, 2017 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codetravis/f27ed03c2d44ec0f05f4119ecea55643 to your computer and use it in GitHub Desktop.
Save codetravis/f27ed03c2d44ec0f05f4119ecea55643 to your computer and use it in GitHub Desktop.
13.4 Add projectile images from sprite sheet
' 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