From ab78a5fc2b109c4d028d1abd197fc1575d9d37ab Mon Sep 17 00:00:00 2001 From: 1029chris <1029chris@gmail.com> Date: Wed, 2 Feb 2022 15:12:58 -0800 Subject: Bullet collision stuff --- players.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'players.lua') diff --git a/players.lua b/players.lua index 92c3646..60227fa 100644 --- a/players.lua +++ b/players.lua @@ -4,8 +4,11 @@ players = {} function addplayer() playercount += 1 local player = {} + player.health = 3 player.x = 18 player.y = 60 + player.w = 8 + player.h = 8 player.ymov = 0 player.id = playercount player.shootcooldown = 0.0 @@ -24,15 +27,15 @@ function addplayer() function player.update(player) --movement if btn(0, player.id) then - player.x -= 2 + player.x -= 1 elseif btn(1, player.id) then - player.x += 2 + player.x += 1 end if btn(2, player.id) then - player.y -= 2 + player.y -= 1 player.ymov = 1 elseif btn(3, player.id) then - player.y += 2 + player.y += 1 player.ymov = -1 else player.ymov = 0 @@ -41,15 +44,14 @@ function addplayer() player.y = mid(0, player.y, 120) --shooting - player.shootcooldown -= 1/30 + player.shootcooldown -= 1/60 if btn(4, player.id) and player.shootcooldown < 0 then - addbullet(player.x+3, player.y, 4, 0, false) + addbullet(player.x+3, player.y, 2, 0, false) player.shootcooldown = 0.1 end end - add(obj, player) - add(players, #obj) + add(players, player) end addplayer() \ No newline at end of file -- cgit