Skip to content

Commit

Permalink
intital phaser set up
Browse files Browse the repository at this point in the history
  • Loading branch information
alehacker committed Mar 19, 2024
1 parent cbaac24 commit 116d23c
Show file tree
Hide file tree
Showing 30 changed files with 94 additions and 4 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified app/.DS_Store
Binary file not shown.
Binary file modified app/services/.DS_Store
Binary file not shown.
Binary file added app/services/ui/.DS_Store
Binary file not shown.
Binary file added app/services/ui/website/.DS_Store
Binary file not shown.
10 changes: 6 additions & 4 deletions app/services/ui/website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
<html>
<head>
<title>Testing Metamask Wallet</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/phaser-arcade-physics.min.js"></script>
<script src="https://c0f4f41c-2f55-4863-921b-sdk-docs.github.io/cdn/metamask-sdk.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="scripts/engine.js"></script>
<script src="scripts/wallet.js"></script>
<script src="scripts/app.js"></script>
<script src="scripts/init.js"></script>
<script src="scripts/backend/engine.js"></script>
<script src="scripts/backend/wallet.js"></script>
<script src="scripts/backend/app.js"></script>
<script src="scripts/backend/init.js"></script>
</head>
<body>
<h1>Testing Metamask Wallet</h1>
<button id="gameConnect">Game Connect</button>
<button id="gameTables">Game Tables</button>
<!-- <script src="scripts/frontend/index.js"></script> -->
<h2></h2>
<div>
<div id="error"></div>
Expand Down
Binary file added app/services/ui/website/scripts/.DS_Store
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
39 changes: 39 additions & 0 deletions app/services/ui/website/scripts/frontend/game.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
class GameScene extends Phaser.Scene {
constructor() {
super({ key: 'game' });
}

preload() {
// Load UI asset images, fonts, etc. (e.g., button image)
this.load.image('background_image', './assets/greenbackground.png');
this.load.image('one', './assets/one.png');
this.load.image('two', './assets/two.png');
this.load.image('three', './assets/three.png');
this.load.image('four', './assets/four.png');
this.load.image('five', './assets/five.png');
this.load.image('six', './assets/six.png');
}

create() {
// Create UI elements using Phaser objects
const backgroundImage = this.add.image(0, 0, 'background_image');
const connectButton = this.add.image(x, y, 'button_image');
connectButton.setInteractive();
connectButton.on('pointerdown', () => {
// Call your connect function to interact with MetaMask
connect();
// Update UI based on response (e.g., display retrieved accounts)
});

// Add other UI elements here
}
}

const config = {
type: Phaser.AUTO,
width: 800,
height: 600,
scene: [GameScene],
};

const game = new Phaser.Game(config);
12 changes: 12 additions & 0 deletions app/services/ui/website/scripts/frontend/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import MenuScene from './menu.js';
import GameScene from './game.js';
// import EndScene from './end.js';

const config = {
type: Phaser.AUTO,
width: 800,
height: 600,
scene: [MenuScene, GameScene],
};

const game = new Phaser.Game(config);
37 changes: 37 additions & 0 deletions app/services/ui/website/scripts/frontend/menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// This is the first screen of the game. Here the player will connect to wallet
// Find other games or start a new game
class MenuScene extends Phaser.Scene {
constructor() {
super({ key: 'menu' });
}

preload() {
// Load assets for your menu UI (images, fonts)
this.load.image('background_image', './assets/greenbackground.png');
this.load.image('dice_image', './assets/Dice.png');
this.load.image('connect_button', './assets/connectbtn.png');
this.load.image('joingame_button', './assets/joinbtn.png');
this.load.image('newgame_button', './assets/newbtn.png');
}

create() {
// Create and position menu UI elements
const backgroundImage = this.add.image(0, 0, 'background_image');
backgroundImage.setScale(0.5); // Adjust image scale if needed

const connectButton = this.add.image(400, 400, 'connect_button');
connectButton.setInteractive();
const joinButton = this.add.image(400, 400, 'joingame_button');
joinButton.setInteractive();
const newGameButton = this.add.image(400, 400, 'newgame_button');
newGameButton.setInteractive();


// Handle button click to start the game
startButton.on('pointerdown', () => {
this.scene.start('game'); // Start the game scene
});
}
}

export default MenuScene;

0 comments on commit 116d23c

Please sign in to comment.