forked from ghoulsblade/love-webplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close ghoulsblade#14 : Rotation supported with new matrices
- Loading branch information
Showing
12 changed files
with
199 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
function love.conf(t) | ||
t.title = "Passing Clouds" | ||
end |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> | ||
<html> | ||
<head> | ||
<title>Love2D-Webplayer</title> | ||
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> | ||
|
||
<link rel="stylesheet" href="../style.css" type="text/css"> | ||
|
||
<script type="text/javascript" src="../js/weblua/build/liblua.js" ></script> | ||
<script type="text/javascript" src="../js/gamepad.js" ></script> | ||
<script type="text/javascript" src="../js/jquery.js" ></script> | ||
<script type="text/javascript" src="../js/jquery.hotkeys.js" ></script> | ||
<script type="text/javascript" src="../js/utils.js" ></script> | ||
<script type="text/javascript" src="../js/utils.webgl.js" ></script> | ||
<script type="text/javascript" src="../js/love.render.js" ></script> | ||
<script type="text/javascript" src="../js/main.js" ></script> | ||
|
||
<script type="text/javascript" src="../js/love.audio.js" ></script> | ||
<script type="text/javascript" src="../js/love.event.js" ></script> | ||
<script type="text/javascript" src="../js/love.filesystem.js" ></script> | ||
<script type="text/javascript" src="../js/love.font.js" ></script> | ||
<script type="text/javascript" src="../js/love.graphics.js" ></script> | ||
<script type="text/javascript" src="../js/love.image.js" ></script> | ||
<script type="text/javascript" src="../js/love.joystick.js" ></script> | ||
<script type="text/javascript" src="../js/love.keyboard.js" ></script> | ||
<script type="text/javascript" src="../js/love.mouse.js" ></script> | ||
<script type="text/javascript" src="../js/Box2dWeb-2.1.a.3.min.js" ></script> | ||
<script type="text/javascript" src="../js/love.physics.js" ></script> | ||
<script type="text/javascript" src="../js/love.sound.js" ></script> | ||
<script type="text/javascript" src="../js/love.thread.js" ></script> | ||
<script type="text/javascript" src="../js/love.timer.js" ></script> | ||
|
||
<script type="text/javascript"> | ||
gShaderCode_Fragment = LoadShaderCode("../js/fragment.shader"); | ||
gShaderCode_Vertex = LoadShaderCode("../js/vertex.shader"); | ||
</script> | ||
|
||
</head> | ||
<body onload="MainOnLoad(['body.png','cloud_plain.png','ear.png','face.png','love.png'])"> | ||
<a href="https://github.com/ghoulsblade/love-webplayer">Love2D-Webplayer</a><br> | ||
<canvas id="glcanvas" width="800" height="600"> | ||
Your browser doesn't appear to support the HTML5 <code><canvas></code> element. | ||
</canvas> | ||
<div id="output" style="font-family: Courier New,Courier,monospace;"></div> | ||
</body></html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
------------------------------------------------- | ||
-- LOVE: Passing Clouds Demo | ||
-- Website: http://love.sourceforge.net | ||
-- Licence: ZLIB/libpng | ||
-- Copyright (c) 2006-2009 LOVE Development Team | ||
------------------------------------------------- | ||
|
||
function love.load() | ||
|
||
-- The amazing music. | ||
music = love.audio.newSource("prondisk.xm") | ||
|
||
-- The various images used. | ||
body = love.graphics.newImage("body.png") | ||
ear = love.graphics.newImage("ear.png") | ||
face = love.graphics.newImage("face.png") | ||
logo = love.graphics.newImage("love.png") | ||
cloud = love.graphics.newImage("cloud_plain.png") | ||
|
||
-- Set the background color to soothing pink. | ||
love.graphics.setBackgroundColor(0xff, 0xf1, 0xf7) | ||
|
||
-- Spawn some clouds. | ||
for i=1,5 do | ||
spawn_cloud(math.random(-100, 900), math.random(-100, 700), 80 + math.random(0, 50)) | ||
end | ||
|
||
love.graphics.setColor(255, 255, 255, 200) | ||
|
||
love.audio.play(music, 0) | ||
end | ||
|
||
function love.update(dt) | ||
if love.joystick.isDown(1, 1) then | ||
nekochan:update(dt) | ||
nekochan:update(dt) | ||
nekochan:update(dt) | ||
end | ||
nekochan.x = nekochan.x + love.joystick.getAxis(1, 1)*200*dt | ||
nekochan.y = nekochan.y + love.joystick.getAxis(1, 2)*200*dt | ||
if love.keyboard.isDown('up') then | ||
nekochan.y = nekochan.y - 200*dt | ||
end | ||
if love.keyboard.isDown('down') then | ||
nekochan.y = nekochan.y + 200*dt | ||
end | ||
if love.keyboard.isDown('left') then | ||
nekochan.x = nekochan.x - 200*dt | ||
end | ||
if love.keyboard.isDown('right') then | ||
nekochan.x = nekochan.x + 200*dt | ||
end | ||
try_spawn_cloud(dt) | ||
|
||
nekochan:update(dt) | ||
|
||
|
||
-- Update clouds, iterating backwards for safe removal of off-screen ones. | ||
local width = love.graphics.getWidth() | ||
for k=#clouds,1,-1 do | ||
local c = clouds[k] | ||
c.x = c.x + c.s * dt | ||
if c.x > width then | ||
table.remove(clouds, k) | ||
end | ||
end | ||
|
||
end | ||
|
||
function love.draw() | ||
|
||
love.graphics.draw(logo, 400, 380, 0, 1, 1, 128, 64) | ||
|
||
for k, c in ipairs(clouds) do | ||
love.graphics.draw(cloud, c.x, c.y) | ||
end | ||
|
||
nekochan:render() | ||
|
||
end | ||
|
||
function love.keypressed(k) | ||
if k == "r" then | ||
love.filesystem.load("main.lua")() | ||
end | ||
end | ||
|
||
|
||
nekochan = { | ||
x = 400, | ||
y = 250, | ||
a = 0 | ||
} | ||
|
||
function nekochan:update(dt) | ||
self.a = self.a + 10 * dt | ||
end | ||
|
||
function nekochan:render() | ||
love.graphics.push() | ||
love.graphics.rotate(self.a*math.pi/60) | ||
love.graphics.translate(self.x, self.y) | ||
love.graphics.draw(body, 0, 0, 0, 1, 1, 64, 64) | ||
love.graphics.draw(face, 0, 0 + math.sin(self.a/5) * 3, 0, 1, 1, 64, 64) | ||
local r = 1 + math.sin(self.a*math.pi/20) | ||
for i = 1,10 do | ||
love.graphics.draw(ear, 0, 0, (i * math.pi*2/10) + 0/10, 1, 1, 16, 64+10*r) | ||
end | ||
love.graphics.pop() | ||
|
||
end | ||
|
||
-- Holds the passing clouds. | ||
clouds = {} | ||
|
||
cloud_buffer = 0 | ||
cloud_interval = 1 | ||
|
||
-- Inserts a new cloud. | ||
function try_spawn_cloud(dt) | ||
|
||
cloud_buffer = cloud_buffer + dt | ||
|
||
if cloud_buffer > cloud_interval then | ||
cloud_buffer = 0 | ||
spawn_cloud(-512, math.random(-50, 500), 80 + math.random(0, 50)) | ||
end | ||
|
||
end | ||
|
||
function spawn_cloud(xpos, ypos, speed) | ||
table.insert(clouds, { x = xpos, y = ypos, s = speed } ) | ||
end |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters