Skip to content

Commit

Permalink
added some boilerplate code & workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ProbablyComputingSquid committed Feb 20, 2025
1 parent 3bad3e8 commit a5ac37e
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 16 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/esbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: nodejs with esbuild

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Build
run: |
npm install
npm run build
43 changes: 43 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: '.'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<title>sockrates</title>
</head>
<body style="overflow:hidden">
<script src="src/main.js" type="module"></script>
<script src="build.js" type="module"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sockrates",
"type": "module",
"scripts": {
"build": "vite build",
"build": "esbuild src/main.ts > build.js --minify --bundle",
"dev": "vite",
"preview": "vite preview",
"zip": "npm run build && mkdir -p dist && zip -r dist/game.zip dist -x \"**/.DS_Store\""
Expand Down
42 changes: 29 additions & 13 deletions src/main.js → src/main.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
import kaplay from "kaplay";
// import "kaplay/global"; // uncomment if you want to use without the k. prefix
import "kaplay/global"; // uncomment if you want to use without the prefix

const k = kaplay();
kaplay();

k.loadRoot("./"); // A good idea for Itch.io publishing later
k.loadSprite("bean", "sprites/bean.png");
k.loadSprite("sock", "sprites/sock.png");
k.loadSound("boom", "sounds/boom.mp3");
loadRoot("./"); // A good idea for Itch.io publishing later
loadSprite("bean", "sprites/bean.png");
loadSprite("sock", "sprites/Sock.png");
loadSound("boom", "sounds/boom.mp3");

const sockObj = k.add([k.pos(120, 80), k.sprite("sock")]);
const player = add([
pos(120, 80), sprite("sock"), area(), body(), "player"
]);

const SPEED = 200;
onKeyDown("left", () => {
player.move(-SPEED, 0);
})
onKeyDown("right", () => {
player.move(SPEED, 0);
})
onKeyDown("up", () => {
player.move(0, -SPEED);
})
onKeyDown("down", () => {
player.move(0, SPEED);
})

const speed = 200;
let velocity = { x: 0, y: 0 };

/*
let velocity = { x: 0, y: 0 };
window.addEventListener("keydown", (e) => {
switch(e.key.toLowerCase()){
case "w":
Expand Down Expand Up @@ -55,8 +71,8 @@ function update() {
requestAnimationFrame(update);
}
requestAnimationFrame(update);

k.onClick(() => {
k.play("boom");
k.addKaboom(k.mousePos());
*/
onClick(() => {
play("boom");
addKaboom(mousePos());
});

0 comments on commit a5ac37e

Please sign in to comment.