mvp
This commit is contained in:
parent
61b773ac6d
commit
c402593a34
|
@ -2,11 +2,11 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1740126099,
|
"lastModified": 1740367490,
|
||||||
"narHash": "sha256-ozoOtE2hGsqh4XkTJFsrTkNxkRgShxpQxDynaPZUGxk=",
|
"narHash": "sha256-WGaHVAjcrv+Cun7zPlI41SerRtfknGQap281+AakSAw=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "32fb99ba93fea2798be0e997ea331dd78167f814",
|
"rev": "0196c0175e9191c474c26ab5548db27ef5d34b05",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -12,14 +12,14 @@
|
||||||
outputs = { self, nixpkgs, playdate-sdk }:
|
outputs = { self, nixpkgs, playdate-sdk }:
|
||||||
let system = "x86_64-linux";
|
let system = "x86_64-linux";
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
stdenv = pkgs.stdenv;
|
|
||||||
playdate-sdk-pkg = playdate-sdk.packages.${system}.default;
|
playdate-sdk-pkg = playdate-sdk.packages.${system}.default;
|
||||||
in {
|
in {
|
||||||
devShell.${system} = with stdenv; with pkgs;
|
devShell.${system} = with pkgs;
|
||||||
mkShell {
|
mkShell {
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
just
|
just
|
||||||
lua-language-server
|
lua-language-server
|
||||||
|
nushell
|
||||||
playdate-sdk-pkg
|
playdate-sdk-pkg
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
7
justfile
7
justfile
|
@ -1,9 +1,14 @@
|
||||||
bin := "Rush.pdx"
|
bin := "Rush.pdx"
|
||||||
|
playdate_sdk_version := "2.6.2"
|
||||||
|
export PLAYDATE_SDK_PATH := x"~/.local/bin/PlaydateSDK-" + playdate_sdk_version
|
||||||
|
|
||||||
alias b := build
|
alias b := build
|
||||||
build:
|
build:
|
||||||
pdc src {{ bin }}
|
$PLAYDATE_SDK_PATH/bin/pdc src {{ bin }}
|
||||||
|
|
||||||
alias s := simu
|
alias s := simu
|
||||||
simu: build
|
simu: build
|
||||||
PlaydateSimulator {{ bin }}
|
PlaydateSimulator {{ bin }}
|
||||||
|
|
||||||
|
setup:
|
||||||
|
tools/download-sdk.nu {{ playdate_sdk_version }}
|
||||||
|
|
BIN
src/img/player.png
Normal file
BIN
src/img/player.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
47
src/main.lua
47
src/main.lua
|
@ -24,14 +24,13 @@ local playerSprite = nil
|
||||||
-- A function to set up our game environment.
|
-- A function to set up our game environment.
|
||||||
|
|
||||||
function myGameSetUp()
|
function myGameSetUp()
|
||||||
|
|
||||||
-- Set up the player sprite.
|
-- Set up the player sprite.
|
||||||
|
|
||||||
local playerImage = gfx.image.new("Images/playerImage")
|
local playerImage = gfx.image.new("img/player.png")
|
||||||
assert( playerImage ) -- make sure the image was where we thought
|
assert(playerImage) -- make sure the image was where we thought
|
||||||
|
|
||||||
playerSprite = gfx.sprite.new( playerImage )
|
playerSprite = gfx.sprite.new(playerImage)
|
||||||
playerSprite:moveTo( 200, 120 ) -- this is where the center of the sprite is placed; (200,120) is the center of the Playdate screen
|
playerSprite:moveTo(200, 120) -- this is where the center of the sprite is placed; (200,120) is the center of the Playdate screen
|
||||||
playerSprite:add() -- This is critical!
|
playerSprite:add() -- This is critical!
|
||||||
|
|
||||||
-- We want an environment displayed behind our sprite.
|
-- We want an environment displayed behind our sprite.
|
||||||
|
@ -41,17 +40,16 @@ function myGameSetUp()
|
||||||
-- and call :setZIndex() with some low number so the background stays behind
|
-- and call :setZIndex() with some low number so the background stays behind
|
||||||
-- your other sprites.
|
-- your other sprites.
|
||||||
|
|
||||||
local backgroundImage = gfx.image.new( "Images/background" )
|
-- local backgroundImage = gfx.image.new("Images/background")
|
||||||
assert( backgroundImage )
|
-- assert(backgroundImage)
|
||||||
|
|
||||||
gfx.sprite.setBackgroundDrawingCallback(
|
|
||||||
function( x, y, width, height )
|
|
||||||
-- x,y,width,height is the updated area in sprite-local coordinates
|
|
||||||
-- The clip rect is already set to this area, so we don't need to set it ourselves
|
|
||||||
backgroundImage:draw( 0, 0 )
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
|
-- gfx.sprite.setBackgroundDrawingCallback(
|
||||||
|
-- function(x, y, width, height)
|
||||||
|
-- -- x,y,width,height is the updated area in sprite-local coordinates
|
||||||
|
-- -- The clip rect is already set to this area, so we don't need to set it ourselves
|
||||||
|
-- backgroundImage:draw(0, 0)
|
||||||
|
-- end
|
||||||
|
-- )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Now we'll call the function above to configure our game.
|
-- Now we'll call the function above to configure our game.
|
||||||
|
@ -65,23 +63,22 @@ myGameSetUp()
|
||||||
-- Use this function to poll input, run game logic, and move sprites.
|
-- Use this function to poll input, run game logic, and move sprites.
|
||||||
|
|
||||||
function playdate.update()
|
function playdate.update()
|
||||||
|
|
||||||
-- Poll the d-pad and move our player accordingly.
|
-- Poll the d-pad and move our player accordingly.
|
||||||
-- (There are multiple ways to read the d-pad; this is the simplest.)
|
-- (There are multiple ways to read the d-pad; this is the simplest.)
|
||||||
-- Note that it is possible for more than one of these directions
|
-- Note that it is possible for more than one of these directions
|
||||||
-- to be pressed at once, if the user is pressing diagonally.
|
-- to be pressed at once, if the user is pressing diagonally.
|
||||||
|
|
||||||
if playdate.buttonIsPressed( playdate.kButtonUp ) then
|
if playdate.buttonIsPressed(playdate.kButtonUp) then
|
||||||
playerSprite:moveBy( 0, -2 )
|
playerSprite:moveBy(0, -2)
|
||||||
end
|
end
|
||||||
if playdate.buttonIsPressed( playdate.kButtonRight ) then
|
if playdate.buttonIsPressed(playdate.kButtonRight) then
|
||||||
playerSprite:moveBy( 2, 0 )
|
playerSprite:moveBy(2, 0)
|
||||||
end
|
end
|
||||||
if playdate.buttonIsPressed( playdate.kButtonDown ) then
|
if playdate.buttonIsPressed(playdate.kButtonDown) then
|
||||||
playerSprite:moveBy( 0, 2 )
|
playerSprite:moveBy(0, 2)
|
||||||
end
|
end
|
||||||
if playdate.buttonIsPressed( playdate.kButtonLeft ) then
|
if playdate.buttonIsPressed(playdate.kButtonLeft) then
|
||||||
playerSprite:moveBy( -2, 0 )
|
playerSprite:moveBy(-2, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Call the functions below in playdate.update() to draw sprites and keep
|
-- Call the functions below in playdate.update() to draw sprites and keep
|
||||||
|
@ -90,6 +87,4 @@ function playdate.update()
|
||||||
|
|
||||||
gfx.sprite.update()
|
gfx.sprite.update()
|
||||||
playdate.timer.updateTimers()
|
playdate.timer.updateTimers()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
24
tools/download-sdk.nu
Executable file
24
tools/download-sdk.nu
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env nu
|
||||||
|
|
||||||
|
def main [version: string] {
|
||||||
|
let sdk_path = $"~/.local/bin/PlaydateSDK-($version)" | path expand
|
||||||
|
if ($sdk_path | path exists) {
|
||||||
|
print $"SDK already installed at ($sdk_path)"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let sdk_url = $"https://download.panic.com/playdate_sdk/Linux/PlaydateSDK-($version).tar.gz"
|
||||||
|
let out_path = mktemp --tmpdir $"PlaydateSDK-($version)-XXX.tar.gz"
|
||||||
|
|
||||||
|
http get $sdk_url | save --raw --progress --force $out_path
|
||||||
|
|
||||||
|
let parent_dir = $sdk_path | path dirname
|
||||||
|
mkdir $parent_dir
|
||||||
|
let uncompress = tar xf $out_path --directory $parent_dir | complete
|
||||||
|
if $uncompress.exit_code != 0 {
|
||||||
|
print --stderr $uncompress.stderr
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
run-external sudo $"($sdk_path)/setup.sh"
|
||||||
|
}
|
Loading…
Reference in a new issue