Good morning, everyone,
I would like to have some help in my project. My project is as follows: Create a game in P5JS ( of your choice).
I already have the basis of the script and I know what I want to do next but unfortunately I don’t know how to do it!
The game I claim to create is simply a kind of “shooting game”. In the Canvas, I would like to see random targets/zombies appear every 2 or 3 seconds where the goal is to shoot them to eliminate them. When they are affected, I would like them to disappear.
I already have a background, a “Crosshair” instead of the mouse cursor, and now I have to animate the game, it’s at this level that I block: /
I would therefore like to know if my project is feasible thanks to the P5JS. If so, I would like to have solutions/examples of codes that I could use!
To summarize:
-
To make targets appear randomly in the Canvas every 2 3 seconds.
-
When the target is hit, make it disappear.
Thank you in advance,
Ziomix,
Here is the code I have for the moment (script):
const CANVAS_WIDTH=666;
const CANVAS_HEIGHT=500;
var img;
var cross;
var cible;
function preload() {
img=loadImage("asset/background.jpg");
}
function setup() {
createCanvas(CANVAS_WIDTH,CANVAS_HEIGHT);
img=loadImage("asset/background.jpg");
cross=loadImage("asset/crosshair.png");
cible=loadImage("asset/cible.png");
//zombie=loadImage("asset/zombie211x384.png");
}
function draw() {
noCursor(); // enlever le curseur
image(img, 0, 0);
image(cible, 333, 250, height / 7, cross.width / 7, cross.height / 7);
imageMode(CENTER); // permet de centrer le pointeur au centre ^^ ( CORNER par défaut )
image(cross, mouseX, mouseY, height / 10, cross.width / 10, cross.height / 10);
}