Games

Concerning p5.js games you can follow these tutorials:
http://xtec.cat/~fperez5/videojocs.html
You will be using different python libraries, e.g. pygame zero, pygame, matplotlib, tensorflow, Keras,scipy, numpy, scikit-learn.

Concerning pygame zero you have several games in the following link of my drive, you can download only using your iespompeufabra.cat account. You have some resources in my GitHub:
Images and sounds for games.

Astropy Jupyter notebooks.

Ping pong in Processing
[p5js code canvas]
float x;
float y;
float speedx;
float speedy;
float radius;
float gameScore;
float recty;
float easing = 0.1;

void setup() {
size(600,400);
x = 300;
y = 300;
speedx = 20;
speedy = 10;
radius = 20;
frameRate(30);
}

void draw () {
background(0,0,0);
noStroke();
ellipseMode(CENTER);
ellipse(x, y, radius*2, radius*2);
rect(580,mouseY,20,100);
rectMode(CENTER);
textAlign(CENTER);
rect(20,recty,20,100);
rectMode(CENTER);
textSize(30);
text(“SCORE: “+gameScore, 100, 50);

x = x+speedx;
y = y+speedy;

if(y+radius >= height || y-radius <=0) {
speedy = -speedy;
fill(random(255),random(255),random(255));
}

if(x+radius >= width-40 && y + 50 > mouseY && y-50 < mouseY) {
speedx = -speedx+2;
fill(random(255),random(255),random(255));
gameScore++;
}

if(recty > y-radius) {
recty = recty-random(90,100) * easing;
}

if(recty < y-radius) {
recty = recty+random(90,100) * easing;
}

if(x-radius <= 40 && y>= recty-50 && y <= recty+50) {
speedx = -speedx + 2;
}

if(x-radius <= 0) {
textSize(40);
fill(255,255,255);
textAlign(CENTER);
text(“GAME OVER “, width/2, 150);
text(“YOU WON”, width/2, 200);
text(“click anywhere to restart”, width/2, 250);
x = random(80,100);
y = random(20,200);
x = x+speedx;
y = y+speedy;
noLoop();
recty = y;
}

if(x+radius >=width) {
textSize(40);
//fill(255,255,255);
textAlign(CENTER);
text(“GAME OVER “, width/2, 150);
text(“YOU LOST”, width/2, 200);
textSize(20);
text(“click anywhere to restart”, width/2, 240);
x = random(80,100);
y = random(20,200);
x = x+speedx;
y = y+speedy;
recty = y;
noLoop();
}
}

void mouseClicked() {
gameScore = 0;
loop();
redraw();
}
[/p5js]