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:
Mees Roelofsz
2023-11-27 00:30:03 +01:00
3 changed files with 25 additions and 3 deletions

View File

@@ -46,8 +46,6 @@ function life() {
textAlign(CENTER);
text(lives, 500, 20);
if (hit == true) {
playerPosX = 500;
playerPosY = 300;
hit = false;
lives -= 1;
}
@@ -139,7 +137,6 @@ function draw() {
life();
// draw background
background(0, 0, 0, 100);
if (!(lives == 0)) {
// draw player
fill(0, 255, 255)

View File

@@ -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/addons/p5.sound.min.js"></script>
<script src="Serial.js"></script>
<script src="js/basicbullet.js"></script>
<script src="game.js"></script>
</head>
<body>

24
web/js/basicbullet.js Normal file
View 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();
}
}