From 3e06a6d970ae15f1b509f75b319d0e8d8d2cffa2 Mon Sep 17 00:00:00 2001 From: Tyler Scott Date: Thu, 3 Feb 2022 12:57:54 +0700 Subject: [PATCH] Add launcher, level borders --- images/launcher.png | Bin 0 -> 1921 bytes main.lua | 67 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 images/launcher.png diff --git a/images/launcher.png b/images/launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4a6447f2e2fcae04a435d2621910379731baee13 GIT binary patch literal 1921 zcmV-{2Y&d8P)pF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H12M$R@ zK~#90?VU|*6;%|+f5k^>jMmyjYNAq6qai`XpwX4kAnaTT8W3n88WasNqPTJ8LX2N% z;s=_TAg%xfL1YIah7eYe5DA2jD%b)R1(i}$+CCTO)t1h^ee*tM&dj{?OYY`n`riLe z@0q#xo{w9HQ4Q*W`9K>m1(*ah0oMRIpssLT9_R-KfQ!Jdz!6|4umR|cRkdM6$V0#u z;4CnR4E{>mVBxzq1Jh&dhhbEWW?(Jw2bCK{v34H#6nPUFMxtp!p6vZZZy2N70I(al zE$U7hMyXs2Y^OR?sA^2XwiPrPF;Q3ilA2`&@HQ|Z>s1nff=;irM_!ZkM` z3;5fChk<*6yO1|j*#E`9z$?JVA+I-#s?vlE@GwvHK4b@KA+nQIF7?17U{~Qg!~FI^ zps|AAG>np&4P2)9;5-RD8=;P6Kt~82J;>IwVMNXe12baO)Q0#;imgpn#;D1t zLEfVHle%3^9n1s%cIX<}K2TF0Z*ceVTTM|$@@c`nYjp{6z-5IT@DJ`? ztrkUHM#9;F`^oy0rl^QmfV;2TG({Q7r5VY}8$DnSYl@1PqXhdqKstBnjEMOR_Y-xN zrl^Q%!``t#^cl&>DddO1G!>O8Vn4x~ zw?|cx4tojShkdGw%BKY>##hWphT4AMdEf>Ou}S9)!5j98sv;d+j?zw5MU^oPiJ=Q? zBzYvFc_Z)`R!#JOT%qmls)}@QEz~coDyp0(D8F9v5lUFt=YS`H$yJq~3|x!xW3j8y z=eXmu3CJKxGrK7-@BSX74%!>QR^W4F>p$=NgDaG0iD_(imT)7p!rkcK_oTN|h|x?M zee>!H7t{*ZBlFiuwhqju5WN@Dy_t3R!d%_E4TtTxK|CtCnK&oLH!dkhM^gQ

DLxGHo zf$QRzoLtrsyjd2kC@qb_iuJ%xgfog>q!!rISbbtI?F4U}g}X~jVa7VQP`4sF-<%Y&;}h#Ec>mT+@qPs*2)e59wc^&*bWq+aAPEF&}aK8Wpga-~g%h zq77-PMcj%MZ8(o?$5}V;BXt;eN8Fsa9<0b%(MMp?As zPuc7u9dD9m{Khc|JgO(n$O0>I53Zre;maD%+C=yb{v(T<-mK$;0;3_$)7#}96}1$odkXZ&K0g{ z0d58EK|-LMr=$(24_DyhOryC zCF)KZMx`_%1+cq`-Y~k69P%`Ty%6X<9#WKE)~EFmlT3*T}Azks$s9Ltryj^bv(m00000NkvXX Hu0mjfVqJn% literal 0 HcmV?d00001 diff --git a/main.lua b/main.lua index 6da5de9..6442bfc 100644 --- a/main.lua +++ b/main.lua @@ -1,15 +1,72 @@ +local tau = math.pi * 2 local game = {} function love.load(arg) - game.images = {} + game.window_width, game.window_height = love.graphics.getDimensions() - game.images.background = love.graphics.newImage('images/background.png') - game.images.background_width = game.images.background:getWidth() + game.bubble_diameter = 60 + game.bubble_radius = game.bubble_diameter / 2 + + -- vertical distance between bubble center points + game.row_gap = math.ceil(math.sqrt( + (game.bubble_diameter * game.bubble_diameter) - + (game.bubble_radius * game.bubble_radius) + )) + + game.background_image = love.graphics.newImage('images/background.png') + game.background_width = game.background_image:getWidth() + + local bubbles_wide = 8 + local bubbles_high = 14 + game.level_width = bubbles_wide * game.bubble_diameter + game.level_height = (bubbles_high - 1) * game.row_gap + game.bubble_diameter + game.level_x = (game.window_width - game.level_width) / 2 + game.level_y = game.bubble_radius + + game.launcher_image = love.graphics.newImage('images/launcher.png') + game.launcher_height = game.launcher_image:getHeight() + game.launcher_width = game.launcher_image:getWidth() + game.launcher_x = game.window_width / 2 + game.launcher_y = game.level_y + game.level_height + game.bubble_diameter + game.launcher_offset_x = 90 -- rotation point in launcher image + game.launcher_offset_y = game.launcher_height / 2 + game.launcher_rotation = -tau / 4 -- up end function love.draw() - love.graphics.draw(game.images.background, 0, 0) - love.graphics.draw(game.images.background, game.images.background_width, 0) + -- draw background + love.graphics.setColor(1, 1, 1, 1) + love.graphics.draw(game.background_image, 0, 0) + love.graphics.draw(game.background_image, game.background_width, 0) + + -- draw level border + love.graphics.setColor(0, 0, 0, 1) + love.graphics.rectangle( + 'line', + game.level_x, + game.level_y, + game.level_width, + game.level_height + ) + + -- draw launcher + love.graphics.setColor(1, 1, 1, 1) + love.graphics.draw( + game.launcher_image, + game.launcher_x, + game.launcher_y, + game.launcher_rotation, + 1, + 1, + game.launcher_offset_x, + game.launcher_offset_y + ) +end + +function love.mousemoved(x, y, dx, dy, is_touch) + local diff_x = x - game.launcher_x + local diff_y = y - game.launcher_y + game.launcher_rotation = math.atan2(diff_y, diff_x) end function love.keypressed(key, scan_code, is_repeat)