Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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