From 6db4b6f9890d5ad5615f5176b5f3e5f70f7edaba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Geyelin?= Date: Tue, 23 Feb 2021 09:50:20 +0100 Subject: [PATCH] Add Wall API sample. Restore simple level sample. --- content/levels/sample_simple_level/level.lua | 34 +++++++++++++++++++ .../levels/sample_simple_level/manifest.json | 5 +++ .../square500x500_graphic.lua | 7 ++++ content/levels/sample_walls/graphics.lua | 7 ++++ content/levels/sample_walls/level.lua | 16 +++++++++ content/levels/sample_walls/manifest.json | 5 +++ 6 files changed, 74 insertions(+) create mode 100644 content/levels/sample_simple_level/level.lua create mode 100644 content/levels/sample_simple_level/manifest.json create mode 100644 content/levels/sample_simple_level/square500x500_graphic.lua create mode 100644 content/levels/sample_walls/graphics.lua create mode 100644 content/levels/sample_walls/level.lua create mode 100644 content/levels/sample_walls/manifest.json diff --git a/content/levels/sample_simple_level/level.lua b/content/levels/sample_simple_level/level.lua new file mode 100644 index 0000000..62067f5 --- /dev/null +++ b/content/levels/sample_simple_level/level.lua @@ -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) \ No newline at end of file diff --git a/content/levels/sample_simple_level/manifest.json b/content/levels/sample_simple_level/manifest.json new file mode 100644 index 0000000..e52e7a3 --- /dev/null +++ b/content/levels/sample_simple_level/manifest.json @@ -0,0 +1,5 @@ +{ + "name":"Sample: Simple level", + "descriptions":["Simple example that does next to nothing."], + "entry_point":"level.lua" +} \ No newline at end of file diff --git a/content/levels/sample_simple_level/square500x500_graphic.lua b/content/levels/sample_simple_level/square500x500_graphic.lua new file mode 100644 index 0000000..25c5689 --- /dev/null +++ b/content/levels/sample_simple_level/square500x500_graphic.lua @@ -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}} + } +} diff --git a/content/levels/sample_walls/graphics.lua b/content/levels/sample_walls/graphics.lua new file mode 100644 index 0000000..0611ffb --- /dev/null +++ b/content/levels/sample_walls/graphics.lua @@ -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}} + } +} diff --git a/content/levels/sample_walls/level.lua b/content/levels/sample_walls/level.lua new file mode 100644 index 0000000..fc4652d --- /dev/null +++ b/content/levels/sample_walls/level.lua @@ -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) \ No newline at end of file diff --git a/content/levels/sample_walls/manifest.json b/content/levels/sample_walls/manifest.json new file mode 100644 index 0000000..c6aaf05 --- /dev/null +++ b/content/levels/sample_walls/manifest.json @@ -0,0 +1,5 @@ +{ + "name":"Sample: Walls", + "descriptions":["This level contains 2 extra walls."], + "entry_point":"level.lua" +} \ No newline at end of file