Skip to content

Commit

Permalink
Add Wall API sample. Restore simple level sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
jyaif committed Feb 23, 2021
1 parent 6ce9728 commit 6db4b6f
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 0 deletions.
34 changes: 34 additions & 0 deletions content/levels/sample_simple_level/level.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
-- Set how large the level will be.
pewpew.set_level_size(500fx, 500fx)

-- Create an entity at position (0,0) that will hold the background mesh.
local background = pewpew.new_customizable_entity(0fx, 0fx)
pewpew.customizable_entity_set_mesh(background, "/dynamic/square500x500_graphic.lua", 0)

-- Create the player's ship.
local player_x = 250fx
local player_y = 100fx
local player_index = 0 -- there is only one player
pewpew.new_player_ship(player_x, player_y, player_index)

-- Create a "baf" enemy.
local baf_x = 250fx
local baf_y = 400fx
local baf_angle = 0fx
local baf_speed = 10fx
local lifetime = -1 -- Use a negative number to indicate that the lifetime is infinite
pewpew.new_baf(baf_x, baf_y, baf_angle, baf_speed, lifetime)

local time = 0

-- A function that will get called every game tick, which is 30 times per seconds.
function level_tick()
-- Stop the game if the player is dead.
local conf = pewpew.get_player_configuration(player_index)
if conf["has_lost"] == true then
pewpew.stop_game()
end
end

-- Register the `level_tick` function to be called at every game tick.
pewpew.add_update_callback(level_tick)
5 changes: 5 additions & 0 deletions content/levels/sample_simple_level/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name":"Sample: Simple level",
"descriptions":["Simple example that does next to nothing."],
"entry_point":"level.lua"
}
7 changes: 7 additions & 0 deletions content/levels/sample_simple_level/square500x500_graphic.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
meshes = {
{
vertexes = {{0,0}, {500,0}, {500,500}, {0,500}},
colors = {0xffffffff, 0xffff00ff, 0xff00ffff, 0x00ff0000},
segments = {{0,1,2,3,0}}
}
}
7 changes: 7 additions & 0 deletions content/levels/sample_walls/graphics.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
meshes = {
{
vertexes = {{0,0}, {500,0}, {500,500}, {0,500}, {100,200}, {400,200}, {200,100}, {400,300}},
colors = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff},
segments = {{0,1,2,3,0}, {4,5}, {6,7}}
}
}
16 changes: 16 additions & 0 deletions content/levels/sample_walls/level.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Set how large the level will be.
pewpew.set_level_size(500fx, 500fx)

-- Create an entity at position (0,0) that will hold the background mesh.
local background = pewpew.new_customizable_entity(0fx, 0fx)
pewpew.customizable_entity_set_mesh(background, "/dynamic/graphics.lua", 0)

-- Create the walls.
pewpew.add_wall(100fx, 200fx, 400fx, 200fx)
pewpew.add_wall(200fx, 100fx, 400fx, 300fx)

-- Create the player's ship.
local player_x = 250fx
local player_y = 250fx
local player_index = 0 -- there is only one player
pewpew.new_player_ship(player_x, player_y, player_index)
5 changes: 5 additions & 0 deletions content/levels/sample_walls/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name":"Sample: Walls",
"descriptions":["This level contains 2 extra walls."],
"entry_point":"level.lua"
}

0 comments on commit 6db4b6f

Please sign in to comment.