2 Commits

Author SHA1 Message Date
a7b5ea4d6d ci: cambio a main y añado public al gitignore 2023-01-11 13:53:40 +01:00
ce48e0c94b Gitlab CI & cambio de dist a public 2023-01-11 13:29:58 +01:00
10 changed files with 3340 additions and 144 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@
.cache
dist
node_modules
public

20
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,20 @@
image: node:latest
pages:
before_script:
# Install yarn as outlined in (https://yarnpkg.com/lang/en/docs/install/#alternatives-stable)
- curl -o- -L https://yarnpkg.com/install.sh | bash
# Make available in the current terminal
- export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
script:
- yarn install
- yarn build
artifacts:
paths:
- public
only:
- main
cache:
paths:
- .yarn
- node_modules/

View File

@@ -1,124 +0,0 @@
import { AnimatedSprite, Container, Texture } from "pixi.js";
const salmonFrames = ["salmon_f01.png", "salmon_f02.png", "salmon_f03.png"];
export class Scene extends Container {
private readonly screenWidth: number;
private readonly screenHeight: number;
private isGoingUp: boolean = false;
private isGoingDown: boolean = false;
private isGoingLeft: boolean = false;
private isGoingRight: boolean = false;
// We promoted clampy to a member of the class
private salmon: AnimatedSprite;
constructor(screenWidth: number, screenHeight: number) {
super(); // Mandatory! This calls the superclass constructor.
// see how members of the class need `this.`?
this.screenWidth = screenWidth;
this.screenHeight = screenHeight;
this.salmon = new AnimatedSprite(
salmonFrames.map((stringy) => Texture.from(stringy))
);
this.salmon.animationSpeed = 0.15;
this.salmon.scale = { x: 0.4, y: 0.4 };
this.salmon.play();
this.salmon.anchor.set(0.5);
this.salmon.x = this.screenWidth / 2;
this.salmon.y = this.screenHeight / 2;
this.addChild(this.salmon);
document.addEventListener("keyup", this.onKeyUp.bind(this));
document.addEventListener("keydown", this.onKeyDown.bind(this));
}
private onKeyDown(e: KeyboardEvent): void {
console.log("KeyUp event fired!", e);
if (e.key === "ArrowUp") {
this.isGoingUp = true;
}
if (e.key === "ArrowDown") {
this.isGoingDown = true;
}
if (e.key === "ArrowLeft") {
this.isGoingLeft = true;
}
if (e.key === "ArrowRight") {
this.isGoingRight = true;
}
if (e.key === " ") {
this.jump();
}
}
private onKeyUp(e: KeyboardEvent): void {
if (e.key === "ArrowUp") {
this.isGoingUp = false;
}
if (e.key === "ArrowDown") {
this.isGoingDown = false;
}
if (e.key === "ArrowLeft") {
this.isGoingLeft = false;
}
if (e.key === "ArrowRight") {
this.isGoingRight = false;
}
if (e.key === " ") {
this.jump();
}
}
update() {
if (this.isGoingUp) {
this.goUp();
}
if (this.isGoingDown) {
this.goDown();
}
if (this.isGoingLeft) {
this.goLeft();
}
if (this.isGoingRight) {
this.goRight();
}
}
private jump() {
this.goUp(2);
this.goLeft();
this.goUp(2);
this.goLeft(2);
}
private goUp(factor = 1) {
this.salmon.y -= 5 * factor;
}
private goDown(factor = 1) {
this.salmon.y += 5 * factor;
}
private goLeft(factor = 1) {
this.salmon.x -= 5 * factor;
}
private goRight(factor = 1) {
this.salmon.x += 5 * factor;
}
}

View File

@@ -1,26 +1,19 @@
import { Application } from "pixi.js";
import { Scene } from "./Scene";
import { Application, Sprite } from 'pixi.js'
const app = new Application({
view: document.getElementById("pixi-canvas") as HTMLCanvasElement,
resolution: window.devicePixelRatio || 1,
autoDensity: true,
backgroundColor: 0x6495ed,
width: 1280,
height: 720,
view: document.getElementById("pixi-canvas") as HTMLCanvasElement,
resolution: window.devicePixelRatio || 1,
autoDensity: true,
backgroundColor: 0x6495ed,
width: 640,
height: 480
});
// const clampy: Sprite = Sprite.from("clampy.png");
const clampy: Sprite = Sprite.from("clampy.png");
// clampy.anchor.set(0.5);
// clampy.x = app.screen.width / 2;
// clampy.y = app.screen.height / 2;
// app.stage.addChild(clampy);
clampy.anchor.set(0.5);
clampy.x = app.screen.width / 2;
clampy.y = app.screen.height / 2;
const scene: Scene = new Scene(app.screen.width, app.screen.height);
app.stage.addChild(scene);
app.ticker.add(() => {
scene.update()
});
app.stage.addChild(clampy);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

View File

@@ -11,7 +11,7 @@ module.exports = (env, argv) => {
// Your build destination
output: {
path: path.resolve(__dirname, 'dist'),
path: path.resolve(__dirname, 'public'),
filename: 'bundle.js'
},

3306
yarn.lock Normal file

File diff suppressed because it is too large Load Diff