Hey!
I have been looking at old school video games from the nostalgic SymbianOS days. Think of Bounce,Snake, Block Breaker or Pong.
A few articles I checked out are:
All Symbian games from 1997 to 2022
For context I am looking to use this here, I wanted to include a few that get unlocked as a user progresses through the exercises.
I would love to hear from anyone who may have worked on a game or anything similar using p5 or any addons.
jafal
2
Hi
With APDE
float ballX, ballY;
float ballSpeedX = 5;
float ballSpeedY = 3;
float ballSize = 20;
float paddleX;
float paddleY;
float paddleWidth = 150;
float paddleHeight = 25;
int score = 0;
boolean gameOver = false;
void setup() {
fullScreen();
orientation(PORTRAIT);
rectMode(CENTER);
resetGame();
}
void draw() {
background(0); // Classic black background
if (!gameOver) {
updateGame();
drawGame();
} else {
drawGameOver();
}
}
void updateGame() {
// Move ball
ballX += ballSpeedX;
ballY += ballSpeedY;
// Wall collisions (Left and Right)
if (ballX < ballSize/2 || ballX > width - ballSize/2) {
ballSpeedX *= -1;
}
// Wall collision (Top)
if (ballY < ballSize/2) {
ballSpeedY *= -1;
}
// Paddle collision
if (ballY + ballSize/2 >= paddleY - paddleHeight/2 &&
ballY - ballSize/2 <= paddleY + paddleHeight/2) {
if (ballX >= paddleX - paddleWidth/2 && ballX <= paddleX + paddleWidth/2) {
ballSpeedY *= -1.05; // Slightly speed up
ballSpeedX *= 1.05;
ballY = paddleY - paddleHeight/2 - ballSize/2; // Prevent sticking
score++;
}
}
// Bottom wall collision (Game Over)
if (ballY > height) {
gameOver = true;
}
// Smooth touch controls for paddle
if (mousePressed) {
paddleX = lerp(paddleX, mouseX, 0.2);
}
// Keep paddle inside screen bounds
paddleX = constrain(paddleX, paddleWidth/2, width - paddleWidth/2);
}
void drawGame() {
// Draw Ball
fill(255); // Classic white elements
noStroke();
ellipse(ballX, ballY, ballSize, ballSize);
// Draw Paddle
rect(paddleX, paddleY, paddleWidth, paddleHeight);
// Draw Score
textSize(60);
textAlign(CENTER, TOP);
text(score, width/2, 100);
}
void drawGameOver() {
fill(255);
textSize(80);
textAlign(CENTER, CENTER);
text("GAME OVER", width/2, height/2 - 50);
textSize(40);
text("Score: " + score, width/2, height/2 + 30);
text("Tap screen to restart", width/2, height/2 + 100);
}
void mousePressed() {
if (gameOver) {
resetGame();
}
}
void resetGame() {
ballX = width / 2;
ballY = height / 4;
ballSpeedX = 5;
ballSpeedY = 8;
paddleX = width / 2;
paddleY = height - 150; // Placed above the bottom edge for thumb comfort
score = 0;
gameOver = false;
}