Browse Source

beginnings of ui

master
NCLanceman 8 months ago
parent
commit
602265d574
  1. BIN
      assets/asteroid/Asteroid 01 - Base.png
  2. BIN
      assets/asteroid/Asteroid 01 - Explode.png
  3. BIN
      assets/player/autocannon.png
  4. BIN
      assets/ui/base_engine.png
  5. 2
      blaster.lua
  6. 4
      entities/enemy.lua
  7. 4
      entities/player.lua
  8. 8
      main.lua
  9. 21
      ui.lua

BIN
assets/asteroid/Asteroid 01 - Base.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
assets/asteroid/Asteroid 01 - Explode.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

BIN
assets/player/autocannon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
assets/ui/base_engine.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

2
blaster.lua

@ -3,7 +3,7 @@ Blaster = Object:extend()
function Blaster:new(x, y, owner)
self.x = x
self.y = y
self.radius = 10
self.radius = 5
self.height = self.radius * 2
self.width = self.radius * 2
self.speed = 700

4
entities/enemy.lua

@ -17,8 +17,8 @@ function Enemy:new(x, y, radius)
self.type = "enemy"
self.health = 10
self.move_radius = radius
self.speed = 100
self.fireRate = 2
self.speed = 80
self.fireRate = 1
self.destroy = false
self.bounds = { (self.x + 18), (self.x + 44), (self.y + 20), (self.y + 44) }

4
entities/player.lua

@ -58,17 +58,13 @@ function Player:update(dt, enemies)
end
function Player:draw()
--local vert = { self.x, self.y, (self.x - 70), (self.y + 70), (self.x + 70), (self.y + 70) }
--love.graphics.polygon("fill", vert)
local fullHealth = self.image[1][2]
love.graphics.draw(fullHealth, self.x, self.y)
for _, v in ipairs(playerBullets) do
--love.graphics.setColor(v.color)
v:draw()
end
--love.graphics.setColor(1, 1, 1)
end
function Player:keyPressed(key)

8
main.lua

@ -1,13 +1,14 @@
function love.load()
Object = require("scripts.classic")
--require("blaster")
require("entities.player")
require("entities.enemy")
require("ui")
ui = Ui(600, 800)
local window_width = love.graphics.getWidth()
local window_height = love.graphics.getHeight()
player = Player(window_width / 2, window_height * 0.8)
--place the player in the middle of the screen, close to the bottom
player = Player(window_width / 2, window_height * 0.9)
listOfEnemies = {}
@ -31,6 +32,7 @@ function love.update(dt)
end
function love.draw()
ui:draw()
player:draw()
for _, v in ipairs(listOfEnemies) do
v:draw()

21
ui.lua

@ -1,3 +1,24 @@
Ui = Object:extend()
--Set game canvas size
function Ui:new(window_width, window_height)
self.playableSpace = { window_width, window_height, (window_width * 0.25) }
self.score = 0
love.window.setMode((window_width * 1.5), window_height)
end
--set window size
function Ui:draw()
local left_line = self.playableSpace[3]
local right_line = self.playableSpace[1] + self.playableSpace[3]
local window_height = self.playableSpace[2]
love.graphics.line(left_line, 0, left_line, window_height)
love.graphics.line(right_line, 0, right_line, window_height)
end
--set
--display the score
--display player health

Loading…
Cancel
Save