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:
BIN
docs/assets/image.png
Normal file
BIN
docs/assets/image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
@@ -3,16 +3,33 @@
|
|||||||
We hebben een database gemaakt. De tabel heet scores en heeft de volgende kolommen: Naam, Scores.
|
We hebben een database gemaakt. De tabel heet scores en heeft de volgende kolommen: Naam, Scores.
|
||||||
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Om iets in de database te zetten moet je de volgende code gebruiken:
|
Om iets in de database te zetten moet je de volgende code gebruiken:
|
||||||
|
|
||||||
```INSERT INTO Scores (Naam,Score)
|
```sql
|
||||||
VALUES ("henk",413);```
|
INSERT INTO Sessie (Naam, Score)
|
||||||
|
VALUES ("henk", 413);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
We hadden gekozen voor een tabel scores en naam en de andere tabel met Achievements. Om de data netjes en gescheiden te houden.
|
We hadden gekozen voor een tabel scores en naam en de andere tabel met achievement soorten en dan daartussen een relatie zodat we die achievements kunnen koppelen aan een sessie.
|
||||||
|
|
||||||
|
Bij het aanmaken van een sessie hoeven we alleen naam en score in te voeren en dan word de rest automatisch ingevuld.
|
||||||
|
|
||||||
|
Daarna moeten we in php de UserID opvragen zodat we de achievements kunnen koppelen aan de sessie.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$last_id = $conn->insert_id;
|
||||||
|
```
|
||||||
|
Op deze manier krijg je de laatst toegevoegde id en kan je de achievements koppelen aan de sessie.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$sqlAchievement1 = "INSERT INTO Sessie_has_Achievements (Sessie_UserID, Achievements_AchievementID) VALUES ('$last_id', 1)";
|
||||||
|
$conn->query($sqlAchievement1);
|
||||||
|
```
|
||||||
|
Op deze manier word er elke keer een nieuwe rij toegevoegd aan de tabel Sessie_has_Achievements en dus een achievement gekoppelt aan de sessie.
|
||||||
|
|
||||||
Bron: https://www.w3schools.com/sql/sql_insert.asp
|
Bron: https://www.w3schools.com/sql/sql_insert.asp
|
@@ -14,17 +14,11 @@ function homescreen() {
|
|||||||
button(255, 255, 255, width / 2, height / 2, "Start Game")
|
button(255, 255, 255, width / 2, height / 2, "Start Game")
|
||||||
button(255, 255, 255, width / 2, height / 2 + height / 12, "Scores")
|
button(255, 255, 255, width / 2, height / 2 + height / 12, "Scores")
|
||||||
|
|
||||||
push()
|
|
||||||
stroke(4, 217, 255)
|
|
||||||
strokeWeight(5)
|
|
||||||
fill(0, 255, 0, 0)
|
|
||||||
rect(width / 5 * 4, height / 2, width / 4, height / 1.5)
|
|
||||||
pop()
|
|
||||||
//highscores rectangle
|
|
||||||
push()
|
push()
|
||||||
textSize(50)
|
textSize(50)
|
||||||
fill(255, 255, 255)
|
fill(255, 255, 255)
|
||||||
text("Highscores", width / 5, height / 4)
|
text("Highscores", width / 5, height / 4)
|
||||||
|
text("Controls", width / 5 * 4, height / 4)
|
||||||
pop()
|
pop()
|
||||||
|
|
||||||
push()
|
push()
|
||||||
@@ -36,18 +30,15 @@ function homescreen() {
|
|||||||
}
|
}
|
||||||
pop()
|
pop()
|
||||||
|
|
||||||
|
//Scores rectangle
|
||||||
push()
|
push()
|
||||||
stroke(4, 217, 255)
|
stroke(4, 217, 255)
|
||||||
strokeWeight(5)
|
strokeWeight(5)
|
||||||
fill(0, 255, 0, 0)
|
fill(0, 255, 0, 0)
|
||||||
rect(width / 5, height / 2, width / 4, height / 1.5)
|
rect(width / 5, height / 2, width / 4, height / 1.5)
|
||||||
|
rect(width / 5 * 4, height / 2, width / 4, height / 1.5)
|
||||||
pop()
|
pop()
|
||||||
|
|
||||||
push()
|
|
||||||
textSize(50)
|
|
||||||
fill(255, 255, 255)
|
|
||||||
text("Controls", width / 5 * 4, height / 4)
|
|
||||||
pop()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function button(r, g, b, buttonX, buttonY, buttonText) {
|
function button(r, g, b, buttonX, buttonY, buttonText) {
|
||||||
|
Reference in New Issue
Block a user