add README

This commit is contained in:
2026-04-29 23:52:04 +09:00
parent 73130dd8ce
commit 3b019607ec
5 changed files with 45 additions and 7 deletions

View File

@@ -1,10 +1,48 @@
# svelte-P5 Play
A simple template to get you started with p5 svelte and the [p5play](https://p5play.org/index.html) library.
# Nubzuki Jump
- Name: Tomas Horsky
- ID: 20256426
- Email: tomashorsky@kaist.ac.kr
- Git Repository: https://git.prototyping.id/20256426/NubzukiJump
- Demo Video:
## How to use
```bash
npm install
npm run dev
```
## Description of the game
<img src="./public/assets/nubzuki.png" width="140" align="right" style="margin-left: 30px;" />
Nubzuki Jump is a simple 2D platformer game where the player controls a character named Nubzuki. The goal is to jump on platforms and reach as high as possible without falling down. The game features four different types of platforms, which are introduced as the player progresses, the types of platforms are:
1. **Basic platform**
2. **Moving platform** a platform that moves horizontally
3. **Spring platform** boosts the player's jump
4. **One-time platform** disappears after one jump
The player can move only left and right, the jumping is done automatically whenever player lands on platform. Game is controlled either by using the **arrow keys**, or by enabling **camera control** and moving head left or right.
## Code Organization
The code is divided into two main parts, the Svelte app and the game logic inside of `src/game`. The Svelte app is responsible for layout of the page, displaying the leaderboard and handling the game state (start, end, restart). It also contains one component `CameraControl.svelte` which is responsible for enabling camera control and showing reading of head movement.
The game logic is divided into several files:
1. `game.js` - the main file which initializes the game and handles the game loop
2. `player.js` - contains the logic related to the player character, such as movement and player state
3. `platforms.js` - contains logic for creating and managing platforms
4. `platformTypes.js` - handles the creation and behavior of of platforms by type
5. `cameraControl.js` - contains the logic for enabling camera control and reading head movement
6. `constants.js` - contains constants for the game
How that different parts of the code are conected and are communicating can be seen in the following diagram:
<div style="text-align: left;">
<img src="./public/assets/organization_diagram.png"
alt="Organization diagram"
width="500">
</div>
## Issues
The issue I was not able to solve is that when using camera control, the game becomes slower and a little bit laggy. I improved it by lowering the camera resolution and reducing the detection frequency, however its still not perfect but playeble. Other then that, the colisons between player and edges of platform are not always perfect, but nothing terrible.
## Resources and Acknowledgements
- [P5play tutorial](https://p5play.org/learn/sprite) and [P5play documentation](https://p5play.org/docs) - to help me with p5play
- **Github copilot** - to help me write code faster
- **ChatGPT** - mainly for camera controls and for finding bugs in my code

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

View File

@@ -4,14 +4,14 @@ import { cameraInput } from './cameraControl.js';
export function createPlayer() {
const player = new Sprite();
player.scale = 0.20;
player.scale = 0.13;
player.img = "assets/nubzuki.png";
player.bounciness = 0;
player.rotationLock = true;
player.w = 20;
player.w = 25;
player.h = 20;
player.offset.y = 25;
player.offset.y = 30;
player.elevation = 0;
player.x = width / 2;
player.y = height - 80;