test if class works

This commit is contained in:
sam
2023-11-28 14:45:14 +01:00
parent 308c2a4008
commit 3a9674ff46
3 changed files with 8 additions and 6 deletions

View File

@@ -3,8 +3,10 @@ class bullet {
constructor(targetx, targety, radius, speed) { constructor(targetx, targety, radius, speed) {
//"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, //"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 //maar ook in de rest van de class
this.x = targetx; this.targetx = targetx;
this.y = targety; this.targety = targety;
this.x = 500;
this.y = 100;
this.radius = radius; this.radius = radius;
this.speed = speed; this.speed = speed;
@@ -14,7 +16,7 @@ class bullet {
this.y = directionY; this.y = directionY;
// Calculate the initial direction // Calculate the initial direction
direction = createVector(targetX - projectile.x, targetY - projectile.y); direction = createVector(this.targetX - projectile.x, this.targetY - projectile.y);
direction.normalize(); direction.normalize();
} }

View File

@@ -73,8 +73,7 @@ let playerPosY = 300;
let bullets = []; let bullets = [];
let playerSpeed = 5; let playerSpeed = 5;
let radius = 20; let radius = 20;
let myBullet = new bullet(); let myBullet = new bullet();
async function Movementloop() { async function Movementloop() {
if (booleanArray[1]) { if (booleanArray[1]) {
@@ -109,6 +108,7 @@ function setup(){
frameRate(244); frameRate(244);
// disable the outline of shapes // disable the outline of shapes
noStroke(); noStroke();
myBullet(playerPosX, playerPosY, radius, 5);
} }
// the function draw() is called every frame // the function draw() is called every frame

View File

@@ -9,7 +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="basicbullet.js"></script>
<script src="game.js"></script> <script src="game.js"></script>
</head> </head>
<body> <body>