Skip to content

Commit 12a92d6

Browse files
author
Rafael Campos Nunes
committed
Getting rid of the swingers library, and making a new kind of moviment.
1 parent d317286 commit 12a92d6

File tree

7 files changed

+54
-112
lines changed

7 files changed

+54
-112
lines changed

assets/textures/simple_whale.png

255 Bytes
Loading

build/whale-sim.love

-409 KB
Binary file not shown.

src/conf.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ function love.conf(t)
33
t.author = "DaemonLee, MrWhales or Skunk_Giant, Rafael C. Nunes or ranu."
44
t.url = "The Escapecraft.net forums or the Escapecraft IRC server"
55
t.identity = nil -- The name of the save directory (string)
6-
t.version = "0.9.1" -- The LÖVE version this game was made for (string)
7-
t.console = false -- Attach a console (boolean, Windows only)
6+
--t.version = "0.9.1" -- The LÖVE version this game was made for (string)
7+
t.verion = "0.8.0" -- LÖVE on my computer is 0.8.0 (ranu)
8+
t.console = false -- Attach a console (boolean, Windows only)
89

910
t.window.icon = nil -- Filepath to an image to use as the window's icon (string)
1011
t.window.width = 800 -- The window width (number)
@@ -34,4 +35,4 @@ function love.conf(t)
3435
t.modules.system = true -- Enable the system module (boolean)
3536
t.modules.timer = true -- Enable the timer module (boolean)
3637
t.modules.window = true -- Enable the window module (boolean)
37-
end
38+
end

src/gameover.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ gameover = {}
22

33
function gameover.load()
44
if state == "gameover" then
5-
gui.buttons = {}
65
gui.newButton("Ressurect!", 100, 200, "ressurect")
76
gui.newButton("Back to menu", 360, 200, "menu")
87
end
98
end
109

1110
function gameover.draw()
11+
love.graphics.setBackgroundColor(128, 171, 212)
1212
love.graphics.printf("Oh whale, you've been krilled!\n\n", 0, 150, 800, "center")
1313

1414
if state == "gameover" then
@@ -29,5 +29,7 @@ function gameover.update(dt)
2929
]]
3030

3131
-- TODO: A resurrect and a back to menu button.
32-
gui.buttonHover()
32+
if state == "gameover" then
33+
gui.buttonHover()
34+
end
3335
end

src/main.lua

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
]]
44

5-
require("libs/swingers")
65
require("libs/AnAL")
76
require("title")
87
require("credits")
@@ -14,11 +13,8 @@ gui = require "libs/GUI"
1413
debug = false
1514

1615
function love.load()
17-
state = "title"
18-
19-
swingers.start()
20-
gesture = {}
21-
16+
state = "game"
17+
2218
game.load()
2319
title.load()
2420
credits.load()

src/title.lua

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,50 +23,27 @@ function title.draw()
2323
love.graphics.setFont(openSansBold)
2424
love.graphics.setBackgroundColor(128, 171, 212)
2525
love.graphics.printf("Whale Simulator", 0, 80, 300, "center")
26-
--[[ love.graphics.printf("^\nI\nI\nI\nI\nI\n<--------+-------->\nI\nI\nI\nI\nI\nV", 0, 200, 800, "center")
27-
if game.dist(mouseX, mouseY, 400, 200) < (32+32) then
28-
love.graphics.print("\n Swipe up for facts!", mouseX, mouseY)
29-
elseif game.dist(mouseX, mouseY, 400, 450) < (32+32) then
30-
love.graphics.print("\n HERP A DERP!", mouseX, mouseY)
31-
elseif game.dist(mouseX, mouseY, 275, 330) < (32+32) then
32-
love.graphics.print("\n Swipe for credits!", mouseX, mouseY)
33-
elseif game.dist(mouseX, mouseY, 525, 330) < (32+32) then
34-
love.graphics.print("\n Swipe to start!", mouseX, mouseY)
35-
end ]]
3626

3727
-- One call, and everything will be drawn :P
3828
gui.buttonDraw()
3929
end
4030

4131
function title.update(dt)
42-
--[[ mouseX = love.mouse.getX()
43-
mouseY = love.mouse.getY()
44-
swingers.update()
45-
if swingers.checkGesture() then
46-
gesture = swingers.getExtGesture()
47-
end
48-
if gesture[1] == "e" then
49-
state = "game"
50-
table.remove(gesture)
51-
elseif gesture[1] == "w" then
52-
state = "credits"
53-
table.remove(gesture)
54-
elseif gesture[1] == "n" then
55-
state = "facts"
56-
table.remove(gesture)
57-
elseif gesture[1] == "s" then
58-
end
59-
swingers.checkError() ]]
60-
6132
mouseX = love.mouse.getX()
6233
mouseY = love.mouse.getY()
6334

6435
-- check for button hover
65-
gui.buttonHover()
36+
if state == "title" then
37+
gui.buttonHover()
38+
end
6639
end
6740

6841
function love.mousepressed(x, y)
69-
if(state == "title") then
42+
if state == "title" then
43+
gui.buttonClick(x, y)
44+
end
45+
46+
if state == "credits" then
7047
gui.buttonClick(x, y)
7148
end
7249
end

src/whale.lua

Lines changed: 36 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,49 @@
11
whale = {}
22

33
function whale.load()
4-
whale.isHurt = false
5-
whale.hurtRemaining = 0
6-
whale.x = 400
7-
whale.y = 300
8-
whale.dir = 0
9-
whale.speed = 50
10-
whale.hunger = 100
11-
whale.health = 100
12-
local whale_sprite = love.graphics.newImage("assets/textures/whale.png")
13-
whale_sprite:setFilter("nearest", "nearest")
14-
whale_anim = newAnimation(whale_sprite, 32, 64, 1, 3)
15-
local whale_spr = love.graphics.newImage("assets/textures/whale.png")
16-
whale_spr:setFilter("nearest", "nearest")
17-
whale_anim = newAnimation(whale_spr, 32, 64, 1, 3)
4+
whale.isHurt = false
5+
whale.hurtRemaining = 0
6+
whale.x = 400
7+
whale.y = 300
8+
whale.dir = 0
9+
whale.speed = 50
10+
whale.hunger = 100
11+
whale.health = 100
12+
local whale_sprite = love.graphics.newImage("assets/textures/whale.png")
13+
--whale_sprite:setFilter("nearest", "nearest")
14+
--whale_anim = newAnimation(whale_sprite, 32, 64, 1, 3)
1815
end
1916

2017
function whale.draw()
21-
if whale.isHurt then
22-
love.graphics.setColor(255, 0, 0)
23-
else
24-
love.graphics.setColor(255, 255, 255)
25-
end
26-
27-
if whale.dir == "n" then
28-
whale_anim:draw(whale.x, whale.y, 0, 1, 1, 16, 32)
29-
elseif whale.dir == "s" then
30-
whale_anim:draw(whale.x, whale.y, 3.1415926535898, 1, 1, 16, 32)
31-
elseif whale.dir == "w" then
32-
whale_anim:draw(whale.x, whale.y, -1.5707963267949, 1, 1, 16, 32)
33-
elseif whale.dir == "e" then
34-
whale_anim:draw(whale.x, whale.y, 1.5707963267949, 1, 1, 16, 32)
35-
elseif whale.dir == "ne" then
36-
whale_anim:draw(whale.x, whale.y, 0.78539816339745, 1, 1, 16, 32)
37-
elseif whale.dir == "se" then
38-
whale_anim:draw(whale.x, whale.y, 2.3561944901923, 1, 1, 16, 32)
39-
elseif whale.dir == "sw" then
40-
whale_anim:draw(whale.x, whale.y, -2.3561944901923, 1, 1, 16, 32)
41-
elseif whale.dir == "nw" then
42-
whale_anim:draw(whale.x, whale.y, -0.78539816339745, 1, 1, 16, 32)
43-
else
44-
whale_anim:draw(whale.x, whale.y, 0, 1, 1, 16, 32)
18+
if whale.isHurt then
19+
love.graphics.setColor(255, 0, 0)
20+
else
21+
love.graphics.setColor(255, 255, 255)
22+
end
23+
24+
local whaleImage = love.graphics.newImage("assets/textures/simple_whale.png")
25+
26+
if debug == true then
27+
love.graphics.print("atan2: ", 10, 40)
28+
love.graphics.print(angle, 100, 40)
29+
love.graphics.print("MouseX: ", 10, 60)
30+
love.graphics.print(mouseX, 100, 60)
31+
love.graphics.print("MouseY: ", 10, 80)
32+
love.graphics.print(mouseY, 100, 80)
4533
end
34+
35+
love.graphics.draw(whaleImage, whale.x, whale.y, angle, 1, 1, 16, 32)
36+
4637
end
4738

4839
function whale.update(dt)
49-
--[[ swingers.update()
50-
if swingers.checkGesture() then
51-
gesture = swingers.getExtGesture()
52-
end ]]
53-
54-
--[[ if gesture[1] ~= nil then
55-
whale.dir = gesture[1]
56-
end
57-
58-
if whale.dir == "n" then
59-
whale.y = whale.y - (whale.speed*dt)
60-
elseif whale.dir == "s" then
61-
whale.y = whale.y + (whale.speed*dt)
62-
elseif whale.dir == "w" then
63-
whale.x = whale.x - (whale.speed*dt)
64-
elseif whale.dir == "e" then
65-
whale.x = whale.x + (whale.speed*dt)
66-
elseif whale.dir == "ne" then
67-
whale.y = whale.y - math.sin(whale.speed*dt)
68-
whale.x = whale.x + math.sin(whale.speed*dt)
69-
elseif whale.dir == "se" then
70-
whale.y = whale.y + math.sin(whale.speed*dt)
71-
whale.x = whale.x + math.sin(whale.speed*dt) -- THIS IS WRONG!
72-
elseif whale.dir == "sw" then
73-
whale.y = whale.y + math.sin(whale.speed*dt)
74-
whale.x = whale.x - math.sin(whale.speed*dt)
75-
elseif whale.dir == "nw" then
76-
whale.y = whale.y - math.sin(whale.speed*dt)
77-
whale.x = whale.x - math.sin(whale.speed*dt)
78-
end ]]
79-
whale_anim:update(dt)
80-
--swingers.checkError()
40+
--whale_anim:update(dt)
41+
42+
mouseX = love.mouse.getX()
43+
mouseY = love.mouse.getY()
44+
45+
angle = math.atan2(mouseY-whale.y, mouseX-whale.x)
46+
8147

8248

8349
if whale.x < 0 then

0 commit comments

Comments
 (0)