Compare commits

...

2 Commits

Author SHA1 Message Date
lee2sman 1e8902b90c got character movement down to some degree. there's no error checking
for example if the character has hit the edge or collided with anything.
it's also not yet checking if what space the character is on. need to
figure out a way to check with the saved 2d array grid.
2022-05-09 00:43:21 -04:00
lee2sman 0a5888fe1d update README.md 2022-05-09 00:43:16 -04:00
2 changed files with 100 additions and 12 deletions

View File

@ -14,12 +14,30 @@ Built in Love2d.
[Devlog thread on Mastodon](https://merveilles.town/web/@exquisitecorp/108264753547723259)
### Inspiration
## Inspiration
[The Beachcomber - audio excerpt from Ocean Hour - rebroadcast on This American Life](https://www.thisamericanlife.org/714/day-at-the-beach/act-three-13)
[Discobog - Algobog DJed episode by Saltzshaker on WFMU](https://wfmu.org/playlists/shows/108956)
[Quiltfolk by me](https://notapipe.itch.io/quiltfolk)
### Command line incantations
Make these into aliases or functions if you'll use them a lot. Replacing the inputfile with $argv in fish or equivalent in Bash/zsh.
Convert spritesheet inputfile to animated gif via imagemagick, for sharing
```
convert -dispose previous inputfile.png -crop 400x500 +adjoin +repage -adjoin -loop 0 -delay 1 output-2.gif
```
Get dimensions of an image or video file via ffmpeg's ffprobe option.
```
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 inputfile.png
```
### Tutorials
[Render Isometric Tiles](https://love2d.org/wiki/Tutorial:Isometric_Graphics)
@ -34,3 +52,5 @@ Built in Love2d.
CC-BY-3.0
[Isometric Character by Elska](https://elska.itch.io/isometric-being)
[pix2pix-tensorflow](https://affinelayer.com/pixsrv/)

View File

@ -5,7 +5,7 @@ function love.load()
--load graphics
dirt = love.graphics.newImage("assets/img/dirt.png")
grass = love.graphics.newImage("assets/img/grass.png")
player_dr = newAnimation(love.graphics.newImage("assets/img/player/DR.png"),20,25,1)
player_dr = newAnimation(love.graphics.newImage("assets/img/animation/player-test-size.png"),20,30,1)
block_width = grass:getWidth()
block_height = grass:getHeight()
@ -28,10 +28,73 @@ end
function love.keypressed(key)
--test, play a drone sound on any keypress
drone[math.random(#drone)]:play()
if player_dir == 'downright' then
if key == 'down' or key == 'right' then
player_x = player_x + block_width/2
player_y = player_y + block_height/4
elseif key == 'up' then
player_x = player_x + block_width/2
player_y = player_y - block_height/4
player_dir = 'upright'
elseif key == 'left' then
player_x = player_x - block_width/2
player_y = player_y + block_height/4
player_dir = 'downleft'
end
elseif player_dir == 'upright' then
if key == 'down' then
player_x = player_x + block_width/2
player_y = player_y + block_height/4
player_dir = 'downright'
elseif key == 'right' or key == 'up' then
player_x = player_x + block_width/2
player_y = player_y - block_height/4
elseif key == 'left' then
player_x = player_x - block_width/2
player_y = player_y - block_height/4
player_dir = 'upleft'
end
elseif player_dir == 'upleft' then
if key == 'left' or key == 'up' then
player_x = player_x - block_width/2
player_y = player_y - block_height/4
elseif key == 'down' then
player_x = player_x - block_width/2
player_y = player_y + block_height/4
player_dir = 'downleft'
elseif key == 'right' then
player_x = player_x + block_width/2
player_y = player_y - block_height/4
player_dir = 'upright'
end
elseif player_dir == 'downleft' then
if key == 'down' or key =='left' then
player_x = player_x - block_width/2
player_y = player_y + block_height/4
elseif key == 'up' then
player_x = player_x - block_width/2
player_y = player_y - block_height/4
player_dir = 'upleft'
elseif key == 'right' then
player_x = player_x + block_width/2
player_y = player_y + block_height/4
player_dir = 'downright'
end
end
--print(grid[player_x][player_y])
--print(player_x)
print(grid[1][1])
--[[
if key == 'up' or key == 'down' or key == 'left' or key == 'right' then
local playerX
local playerY
player_x = playerX + block_width/2
player_y = playerY + block_height/4
for testY, row in ipairs(level) do
for testX, cell in ipairs(row) do
@ -73,9 +136,11 @@ function love.keypressed(key)
--drone[1]:play()
drone[math.random(#drone)]:play()
end
end
end
end
]]--
end
function love.draw()
@ -117,6 +182,7 @@ end
function create_player()
player_x = grid_x
player_y = grid_y - block_depth * 2
player_dir = "downright" -- either 'downright','upright','downleft','upleft'
end
function draw_grid()
@ -140,6 +206,14 @@ function draw_grid()
end
function draw_player()
local spriteNum = math.floor(player_dr.currentTime / player_dr.duration * #player_dr.quads) + 1
love.graphics.draw(player_dr.spriteSheet, player_dr.quads[spriteNum], player_x, player_y, 0, 2)
end
function newAnimation(image, width, height, duration)
local player_dr = {}
player_dr.spriteSheet = image;
@ -156,9 +230,3 @@ function newAnimation(image, width, height, duration)
return player_dr
end
function draw_player()
local spriteNum = math.floor(player_dr.currentTime / player_dr.duration * #player_dr.quads) + 1
love.graphics.draw(player_dr.spriteSheet, player_dr.quads[spriteNum], player_x, player_y, 0, 2)
end