Merge branch 'main' of ssh://gitlab.fdmci.hva.nl/propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-2/cuujooceevii61
This commit is contained in:
@@ -46,8 +46,6 @@ function life() {
|
|||||||
textAlign(CENTER);
|
textAlign(CENTER);
|
||||||
text(lives, 500, 20);
|
text(lives, 500, 20);
|
||||||
if (hit == true) {
|
if (hit == true) {
|
||||||
playerPosX = 500;
|
|
||||||
playerPosY = 300;
|
|
||||||
hit = false;
|
hit = false;
|
||||||
lives -= 1;
|
lives -= 1;
|
||||||
}
|
}
|
||||||
@@ -139,7 +137,6 @@ function draw() {
|
|||||||
life();
|
life();
|
||||||
// draw background
|
// draw background
|
||||||
background(0, 0, 0, 100);
|
background(0, 0, 0, 100);
|
||||||
|
|
||||||
if (!(lives == 0)) {
|
if (!(lives == 0)) {
|
||||||
// draw player
|
// draw player
|
||||||
fill(0, 255, 255)
|
fill(0, 255, 255)
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.js"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/addons/p5.sound.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/addons/p5.sound.min.js"></script>
|
||||||
<script src="Serial.js"></script>
|
<script src="Serial.js"></script>
|
||||||
|
<script src="js/basicbullet.js"></script>
|
||||||
<script src="game.js"></script>
|
<script src="game.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
24
web/js/basicbullet.js
Normal file
24
web/js/basicbullet.js
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
class bullet {
|
||||||
|
constructor(x, y, angle, speed, radius, color) {
|
||||||
|
//"This" moet gebruikt worden om de variabelen aan te maken in de class en het zorgt er voor dat de variabelen niet alleen in de constructor gebruikt kunnen worden,
|
||||||
|
//maar ook in de rest van de class
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.angle = angle;
|
||||||
|
this.speed = speed;
|
||||||
|
this.radius = radius;
|
||||||
|
this.color = color;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
//push en pop zorgen er voor dat de code tussen push en pop een eigen canvas heeft. Dus dat er meerdere projectielen tegelijk kunnen zijn.
|
||||||
|
push();
|
||||||
|
fill(255, 0, 0);
|
||||||
|
circle(projectile.x, projectile.y, projSize);
|
||||||
|
pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user