Generation

generate functionTue, 11 Apr 2023

Build using js and p5.js: We all recorded a very simple car game. A vertical view of the road, our car following the mouse pointer from side to side to avoid collide with the cars we are overtaking... From this memory we will create our own car game. With everything we know and building little by little all the elements we can go on increasing the gameplay and improving our programming. let's start 1. Create HTML, CSS and JS file. a. A Road, a Car (We can create a class for each one of de ellos, con una aparte visual, is a component of sight). IS convenient for each class to have a method that paints the object. b. The mousemove event allows us to program the movement from our car C. We can make a loop and let the road move. 2. Let's add a matrix of Trucks. (We created the Truck class and it has one part of View, since it is a component of the view, not of the model!). a. Class Truck, it is convenient that each class has a method that paint the object. b. Trucks were automatically created and moved (setInterval). C. We must detect if there are collisions and if they have reached the end of the screen.

if (truck.collision(car) || truck.offscreen()) { truck.speed = 0; gameOver = true; }

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant