Skip to content

Commit ddcd4d2

Browse files
authored
Merge pull request #2 from ednark/feature/vampire-survivor-movement
Feature/vampire survivor movement
2 parents cc124b8 + 8f0c64e commit ddcd4d2

2 files changed

Lines changed: 506 additions & 18 deletions

File tree

vampire-survivor/README.md

Lines changed: 72 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,56 @@
1-
# Vampire Survivor Style Game - Movement Demo
1+
# Vampire Survivor Style Game
22

3-
A web-based vampire survivor style game with thumb-based joystick movement mechanics.
3+
A web-based vampire survivor style game with thumb-based joystick movement mechanics, enemy AI, and auto-attacking weapons.
44

55
## Features
66

77
### ✅ Implemented
88
- **Patterned Background**: Grid pattern with dots at intersections that scrolls as the player moves
99
- **Player Character**: Red square with white border and shadow effect
1010
- **Virtual Joystick**: Touch-friendly joystick control in the bottom-left corner
11-
- **Movement Mechanics**:
11+
- **Movement Mechanics**:
1212
- Smooth 360-degree movement
1313
- Keyboard support (WASD or Arrow keys)
1414
- Touch/mouse joystick support
1515
- Camera follows player
1616
- Normalized diagonal movement
17+
- **Enemy System**:
18+
- Green enemy squares that spawn around the player
19+
- AI that moves enemies towards the player
20+
- Enemies are slightly slower than the player (150 vs 200 speed)
21+
- Enemies have 3 health points
22+
- Collision detection - enemies die when reaching the player
23+
- Automatic spawning every 2 seconds
24+
- Maximum of 50 enemies on screen
25+
- Spawn distance of 400 pixels from player
26+
- **Weapon System**:
27+
- Blue star weapon pickup spawns near player
28+
- Collectible by walking over it
29+
- Once collected, auto-fires small yellow star projectiles
30+
- Fires every 0.5 seconds at the nearest enemy
31+
- Projectiles deal 1 damage per hit
32+
- Smart targeting system finds closest enemy
33+
- Projectiles despawn after traveling 800 pixels
1734
- **Game Loop**: Proper delta-time based game loop for consistent movement
18-
- **Info Display**: Real-time position and velocity display
35+
- **Info Display**: Real-time position, velocity, enemy count, kill counter, and weapon status
1936

2037
## How to Play
2138

22-
### Desktop
39+
### Controls
40+
**Desktop:**
2341
- Use **WASD** or **Arrow Keys** to move
2442
- Or click and drag the joystick in the bottom-left corner
2543

26-
### Mobile/Touch Devices
44+
**Mobile/Touch Devices:**
2745
- Touch and drag the joystick in the bottom-left corner to move
2846

47+
### Gameplay
48+
1. Move around to avoid the green enemies
49+
2. Collect the blue star weapon pickup
50+
3. Once collected, your character will automatically fire yellow star projectiles at the nearest enemy
51+
4. Survive as long as possible and rack up kills!
52+
5. Enemies have 3 health, so it takes 3 hits to kill them
53+
2954
## Running the Game
3055

3156
Simply open [`index.html`](index.html:1) in a web browser. No build process or dependencies required!
@@ -51,36 +76,68 @@ You can also view this game via GitHub Pages or any static hosting service.
5176
- **Canvas-based rendering**: Uses HTML5 Canvas API for 2D graphics
5277
- **Delta-time game loop**: Ensures consistent movement across different frame rates
5378
- **Responsive design**: Adapts to any screen size
79+
- **Object-oriented enemies**: Enemy class with update and draw methods
5480

5581
### Controls Implementation
5682
- **Keyboard**: Event listeners for keydown/keyup
5783
- **Joystick**: Touch and mouse event handlers with visual feedback
5884
- **Input normalization**: Diagonal movement is normalized to prevent faster diagonal speed
5985

86+
### Enemy AI
87+
- **Pathfinding**: Simple direct movement towards player position
88+
- **Speed balancing**: Enemies move at 75% of player speed (150 vs 200)
89+
- **Health system**: Enemies have 3 health points
90+
- **Collision detection**: Circle-based collision using center points
91+
- **Spawning**: Random angle around player at fixed distance
92+
- **Lifecycle**: Enemies removed on collision with player or when health reaches 0
93+
94+
### Weapon System
95+
- **Pickup spawning**: Blue star spawns 200 pixels from player
96+
- **Collection**: Walk over the blue star to collect it
97+
- **Auto-targeting**: Automatically finds and targets nearest enemy
98+
- **Fire rate**: Shoots every 0.5 seconds
99+
- **Projectile speed**: 300 pixels per second
100+
- **Damage**: 1 damage per hit (3 hits to kill an enemy)
101+
- **Visual feedback**: Rotating star animations for both pickup and projectiles
102+
- **Smart cleanup**: Projectiles removed after hitting enemy or traveling too far
103+
60104
### Performance
61105
- Efficient rendering with requestAnimationFrame
62106
- Pattern background uses modulo math for infinite scrolling
63107
- Camera system keeps player centered on screen
108+
- Array cleanup for destroyed enemies
64109

65110
## Future Enhancements
66111

67112
Potential additions for a full vampire survivor game:
68-
- Enemy spawning and AI
69-
- Weapon systems (auto-attacking)
70-
- Experience and leveling
71-
- Power-up selection
72-
- Health system
73-
- Wave-based progression
113+
-~~Enemy spawning and AI~~ (Implemented!)
114+
-~~Weapon systems (auto-attacking projectiles)~~ (Implemented!)
115+
- Multiple weapon types (area damage, piercing, etc.)
116+
- Weapon upgrades and evolution
117+
- Experience and leveling system
118+
- Power-up selection on level up
119+
- Player health system and damage from enemies
120+
- Wave-based progression with increasing difficulty
121+
- Different enemy types with varied behaviors
74122
- Sound effects and music
75-
- Particle effects
123+
- Particle effects for hits/deaths
76124
- Multiple character types
125+
- Boss enemies
126+
- Persistent upgrades
127+
- Score multipliers and combos
77128

78129
## Code Structure
79130

80-
- **Game State**: Central game object managing player, camera, and input
81-
- **Rendering**: Separate functions for background and player rendering
131+
- **Game State**: Central game object managing player, enemies, weapons, projectiles, camera, and input
132+
- **WeaponPickup Class**: Blue star collectible with rotation animation
133+
- **Projectile Class**: Auto-targeting yellow star projectiles with collision detection
134+
- **Enemy Class**: Object-oriented enemy with health, AI, collision, and rendering
135+
- **Rendering**: Separate functions for background, pickups, enemies, projectiles, and player
82136
- **Input Handling**: Unified input system supporting both keyboard and joystick
83137
- **Update Loop**: Physics and game logic updates based on delta time
138+
- **Spawning System**: Timer-based enemy and weapon pickup spawning
139+
- **Targeting System**: Finds nearest enemy for auto-aim functionality
140+
- **Damage System**: Health-based enemy damage with kill tracking
84141

85142
## Browser Compatibility
86143

0 commit comments

Comments
 (0)