Bladeren bron

Final commit

Adam 4 dagen geleden
bovenliggende
commit
6d1411c2b3

+ 6 - 0
android/.idea/AndroidProjectSystem.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="AndroidProjectSystem">
+    <option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
+  </component>
+</project>

+ 6 - 0
android/.idea/compiler.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <bytecodeTargetLevel target="21" />
+  </component>
+</project>

+ 17 - 0
android/.idea/deploymentTargetDropDown.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="deploymentTargetDropDown">
+    <runningDeviceTargetSelectedWithDropDown>
+      <Target>
+        <type value="RUNNING_DEVICE_TARGET" />
+        <deviceKey>
+          <Key>
+            <type value="SERIAL_NUMBER" />
+            <value value="9125288102E0" />
+          </Key>
+        </deviceKey>
+      </Target>
+    </runningDeviceTargetSelectedWithDropDown>
+    <timeTargetWasSelectedWithDropDown value="2026-05-10T09:15:06.186310700Z" />
+  </component>
+</project>

+ 11 - 0
android/.idea/deploymentTargetSelector.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="deploymentTargetSelector">
+    <selectionStates>
+      <SelectionState runConfigName="app">
+        <option name="selectionMode" value="DROPDOWN" />
+        <DialogSelection />
+      </SelectionState>
+    </selectionStates>
+  </component>
+</project>

+ 25 - 0
android/.idea/jarRepositories.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="RemoteRepositoriesConfiguration">
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Maven Central repository" />
+      <option name="url" value="https://repo1.maven.org/maven2" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="jboss.community" />
+      <option name="name" value="JBoss Community repository" />
+      <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="MavenRepo" />
+      <option name="name" value="MavenRepo" />
+      <option name="url" value="https://repo.maven.apache.org/maven2/" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="Google" />
+      <option name="name" value="Google" />
+      <option name="url" value="https://dl.google.com/dl/android/maven2/" />
+    </remote-repository>
+  </component>
+</project>

+ 10 - 0
android/.idea/migrations.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectMigrations">
+    <option name="MigrateToGradleLocalJavaHome">
+      <set>
+        <option value="$PROJECT_DIR$" />
+      </set>
+    </option>
+  </component>
+</project>

+ 1 - 1
android/.idea/misc.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="ExternalStorageConfigurationManager" enabled="true" />
-  <component name="ProjectRootManager" version="2" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/build/classes" />
   </component>
   <component name="ProjectType">

+ 17 - 0
android/.idea/runConfigurations.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="RunConfigurationProducerService">
+    <option name="ignoredProducers">
+      <set>
+        <option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
+        <option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
+        <option value="com.intellij.execution.junit.PatternConfigurationProducer" />
+        <option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
+        <option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
+        <option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
+        <option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
+        <option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
+      </set>
+    </option>
+  </component>
+</project>

+ 6 - 0
android/.idea/studiobot.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="StudioBotProjectSettings">
+    <option name="shareContext" value="OptedIn" />
+  </component>
+</project>

BIN
android/app/release/baselineProfiles/0/app-release.dm


BIN
android/app/release/baselineProfiles/1/app-release.dm


+ 37 - 0
android/app/release/output-metadata.json

@@ -0,0 +1,37 @@
+{
+  "version": 3,
+  "artifactType": {
+    "type": "APK",
+    "kind": "Directory"
+  },
+  "applicationId": "com.example.app",
+  "variantName": "release",
+  "elements": [
+    {
+      "type": "SINGLE",
+      "filters": [],
+      "attributes": [],
+      "versionCode": 1,
+      "versionName": "1.0",
+      "outputFile": "app-release.apk"
+    }
+  ],
+  "elementType": "File",
+  "baselineProfiles": [
+    {
+      "minApi": 28,
+      "maxApi": 30,
+      "baselineProfiles": [
+        "baselineProfiles/1/app-release.dm"
+      ]
+    },
+    {
+      "minApi": 31,
+      "maxApi": 2147483647,
+      "baselineProfiles": [
+        "baselineProfiles/0/app-release.dm"
+      ]
+    }
+  ],
+  "minSdkVersionForDexing": 24
+}

+ 1 - 1
android/build.gradle

@@ -7,7 +7,7 @@ buildscript {
         mavenCentral()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:8.13.0'
+        classpath 'com.android.tools.build:gradle:8.13.2'
         classpath 'com.google.gms:google-services:4.4.4'
 
         // NOTE: Do not place your application dependencies here; they belong

+ 2 - 1
android/gradle/wrapper/gradle-wrapper.properties

@@ -1,6 +1,7 @@
+#Sun May 10 11:18:50 CEST 2026
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
 networkTimeout=10000
 validateDistributionUrl=true
 zipStoreBase=GRADLE_USER_HOME

BIN
www/BoxJump.zip


+ 98 - 38
www/js/main.js

@@ -22,7 +22,7 @@ class MyGame extends Phaser.Scene {
 
     this.cursor;
     this.playerSpeed = 300;
-    this.playerStart = {x: 400, y: 0};
+    this.playerStart = {x: 0, y: 0};
     this.playerJumpVelocity = -500;
     this.goalX = 5000;
 
@@ -36,15 +36,22 @@ class MyGame extends Phaser.Scene {
 
     this.spikes;
 
-    this.controls = {
-      left: false,
-      right: false,
-      jump: false
-    }
+    this.moveLeft = false;
+    this.moveRight = false;
+    this.jumpPressed = false;
 
 
     this.test = Phaser.Physics.Arcade.World;
 
+    this.buttonY = 400;
+
+    this.leftBtnX = -400;
+    this.leftBtn;
+    this.rightBtnX = -280;
+    this.rightBtn;
+    this.jumpBtnX = 700;
+    this.jumpBtn;
+
   }
 
   preload() {
@@ -65,6 +72,79 @@ class MyGame extends Phaser.Scene {
 
 
 
+    
+    //#region Input
+
+    this.input.addPointer(2);
+
+    // Track button states
+
+
+    // LEFT BUTTON
+    this.leftBtn = this.add.rectangle(this.leftBtnX, this.buttonY, 100, 100, 0x0000ff, 1)
+      .setInteractive();
+
+    this.leftBtnPlayerDistanceX = this.playerStart.x - this.leftBtnX;
+    
+
+    this.leftBtn.on("pointerdown", () => {
+      this.moveLeft = true;
+    });
+
+    this.leftBtn.on("pointerup", () => {
+      this.moveLeft = false;
+    });
+
+    this.leftBtn.on("pointerout", () => {
+      this.moveLeft = false;
+    });
+
+    // RIGHT BUTTON
+    this.rightBtn = this.add.rectangle(this.rightBtnX, this.buttonY, 100, 100, 0x00ff00, 0.5)
+      .setInteractive();
+
+    this.rightBtnPlayerDistanceX = this.playerStart.x - this.rightBtnX;
+
+
+    this.rightBtn.on("pointerdown", () => {
+      this.moveRight = true;
+    });
+
+    this.rightBtn.on("pointerup", () => {
+      this.moveRight = false;
+    });
+
+    this.rightBtn.on("pointerout", () => {
+      this.moveRight = false;
+    });
+
+    // JUMP BUTTON
+    this.jumpBtn = this.add.rectangle(this.jumpBtnX, this.buttonY, 100, 100, 0xff0000, 0.5)
+      .setInteractive();
+
+    this.jumpBtnPlayerDistanceX = this.playerStart.x - this.jumpBtnX;
+
+
+    this.jumpBtn.on("pointerdown", () => {
+      this.jumpPressed = true;
+    });
+
+    this.jumpBtn.on("pointerup", () => {
+      this.jumpPressed = false;
+    });
+
+    this.jumpBtn.on("pointerout", () => {
+      this.jumpPressed = false;
+    });
+
+    //#endregion
+
+
+
+
+
+
+
 
     this.player = this.physics.add.image(this.playerStart.x, this.playerStart.y,"redSquare").setOrigin(0,0); //https://newdocs.phaser.io/docs/3.55.2/Phaser.Physics.Arcade.Factory#image
     this.player.setBounce(0); //https://newdocs.phaser.io/docs/3.55.2/Phaser.Physics.Arcade.Body#setBounce
@@ -125,21 +205,17 @@ class MyGame extends Phaser.Scene {
 
     //#region Camera
     //(follow Target, round pixel to int, lerpX, lerpY, offsetX, offsetY) //https://newdocs.phaser.io/docs/3.60.0/focus/Phaser.Cameras.Scene2D.Camera-startFollow
-    this.cameras.main.startFollow(this.player, false, 1, 0, 0, 0); 
+    this.cameras.main.startFollow(this.player, false, 1, 0, 0, -100); 
 
     this.cameras.main.backgroundColor= "black";
 
     this.cameras.main.setViewport(-config.width / 2, -config.height/2, config.width*2, config.height*2);
 
-    //#endregion
-
-
-    //#region Input
-
-    this.input.addPointer(2);
+    this.cameras.main.zoom = 0.5;
 
     //#endregion
 
+
     //#region HUD
 
     //this.playerText = this.add.text(10, 10, 'Position: (0, 0)', { fontSize: '16px', fill: '#00FF00' });
@@ -156,38 +232,21 @@ class MyGame extends Phaser.Scene {
     //#region Input Manager
     const {left, right, space} = this.cursor;
 
-    this.controls = {
-      left: false,
-      right: false,
-      jump: false
-    };
-
-
-    const w = window.innerWidth;
-    const h = window.innerHeight;
 
-    if (pointer.y > h * 0.7) {
-      this.controls.jump = true;
-    } else if (pointer.x < w / 2) {
-      this.controls.left = true;
-    } else {
-      this.controls.right = true;
-    }
 
 
-    console.log(this.controls);
 
-    if (left.isDown || this.controls.left){
+    if (left.isDown || this.moveLeft){
       console.log("left press");
       this.player.setVelocityX(-this.playerSpeed);
-    } else if (right.isDown || this.controls.right){
+    } else if (right.isDown || this.moveRight){
       console.log("right press");
       this.player.setVelocityX(this.playerSpeed);
     } else {
       this.player.setVelocityX(0);
     }
 
-    if (space.isDown || this.controls.jump && onGround){
+    if ((space.isDown || this.jumpPressed) && onGround){
       this.player.setVelocityY(this.playerJumpVelocity);
     }
 
@@ -196,8 +255,9 @@ class MyGame extends Phaser.Scene {
 
     //#region Update HUD
 
-    //this.playerText.setText('Position: ('+this.player.x.toFixed(0)+', '+ this.player.y.toFixed(0)+')');
-
+    this.leftBtn.setPosition(this.player.x - this.leftBtnPlayerDistanceX, this.buttonY);
+    this.rightBtn.setPosition(this.player.x - this.rightBtnPlayerDistanceX, this.buttonY);
+    this.jumpBtn.setPosition(this.player.x - this.jumpBtnPlayerDistanceX, this.buttonY);
 
     //#endregion
 
@@ -206,7 +266,7 @@ class MyGame extends Phaser.Scene {
       this.scene.restart();
       alert("You lost.");
     } else if (this.player.x > this.goalX){
-      this.scene.stop();
+      this.scene.restart()
       alert("You won!");
     }
 
@@ -221,8 +281,8 @@ class MyGame extends Phaser.Scene {
 
 const config = {
   type: Phaser.AUTO,
-  width: window.innerWidth,
-  height: window.innerHeight,
+  width: window.innerWidth - 10,
+  height: window.innerHeight- 10,
   backgroundColor: "#ffffff", //sets the background color of the scene
   scene: MyGame,
   physics: {