Now Works as it did before all the rollup.
This commit is contained in:
parent
d428eb3efe
commit
288108282f
|
@ -2,3 +2,4 @@ import './display/draw.js';
|
||||||
import './game/game.js'
|
import './game/game.js'
|
||||||
import './interface/mainmenu/menu.js'
|
import './interface/mainmenu/menu.js'
|
||||||
import './net/netcode.js'
|
import './net/netcode.js'
|
||||||
|
import './interface/game/mouse.js'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import {game} from "../../game/game.js";
|
import {game} from "../../game/game.js";
|
||||||
import { clickCanvas } from "../../net/netcode.js";
|
import * as net from "../../net/netcode.js";
|
||||||
import { canvas } from "../../display/html.js"
|
import { canvas } from "../../display/html.js"
|
||||||
|
|
||||||
class Cursor {
|
class Cursor {
|
||||||
|
@ -17,9 +17,8 @@ canvas.addEventListener('mousemove', e => {
|
||||||
mouseMoved(e)
|
mouseMoved(e)
|
||||||
});
|
});
|
||||||
|
|
||||||
canvas.addEventListener("mousedown", function(e)
|
canvas.addEventListener("mousedown", e => {
|
||||||
{
|
getMousePosition(e);
|
||||||
getMousePosition(canvas, e);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function mouseMoved(event) {
|
function mouseMoved(event) {
|
||||||
|
@ -35,7 +34,7 @@ function mouseMoved(event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMousePosition(canvas, event) {
|
function getMousePosition(event) {
|
||||||
const tileSize = game.tileSize
|
const tileSize = game.tileSize
|
||||||
// Get mouse position on canvas
|
// Get mouse position on canvas
|
||||||
const rect = canvas.getBoundingClientRect();
|
const rect = canvas.getBoundingClientRect();
|
||||||
|
@ -48,6 +47,6 @@ function getMousePosition(canvas, event) {
|
||||||
|
|
||||||
console.log("Click!")
|
console.log("Click!")
|
||||||
console.log(xu,yu)
|
console.log(xu,yu)
|
||||||
clickCanvas({tilePosition: [xu,yu], mode: button})
|
net.clickCanvas({tilePosition: [xu,yu], mode: button})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {joinGame, createGame} from "../../net/netcode.js"
|
import * as net from "../../net/netcode.js"
|
||||||
import { changeScene } from "../scene.js"
|
import { changeScene } from "../scene.js"
|
||||||
import {Picker} from "./picker.js"
|
import {Picker} from "./picker.js"
|
||||||
import {tileArray, menuArray} from "../../display/tileRenderer.js"
|
import {tileArray, menuArray} from "../../display/tileRenderer.js"
|
||||||
|
@ -15,7 +15,7 @@ export function init(){
|
||||||
}
|
}
|
||||||
|
|
||||||
ID("createRoomButton").addEventListener("click", e => {
|
ID("createRoomButton").addEventListener("click", e => {
|
||||||
create(e)
|
createGameClick(e)
|
||||||
});
|
});
|
||||||
|
|
||||||
const mineSlider = ID("createGameOptionsMinePercent")
|
const mineSlider = ID("createGameOptionsMinePercent")
|
||||||
|
@ -150,25 +150,14 @@ function updatePercentageLabel(percentage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function create(event) {
|
function createGameClick(event) {
|
||||||
const name = ID("createGameUsername").value
|
const name = ID("createGameUsername").value
|
||||||
const mines = ID("createGameOptionsMines").value
|
const width = Number(widthBox.value);
|
||||||
const width = widthBox.value;
|
const height = Number(heightBox.value);
|
||||||
const height = heightBox.value;
|
const color = Number(colorPicker.selected);
|
||||||
const color = colorPicker.selected
|
|
||||||
if (name == '' || mines == '' || width == '' || height == '' || status.get() == 'disconnected') return
|
if (name == '' || mines == '' || width == '' || height == '' || status.get() == 'disconnected') return
|
||||||
const options = {
|
const options = { mines: mines, width: width, height: height};
|
||||||
mines: mines,
|
const data = {name: name, color: color, options: options};
|
||||||
width: width,
|
net.createGame(data)
|
||||||
height: height
|
|
||||||
}
|
|
||||||
const data =
|
|
||||||
{
|
|
||||||
name: name,
|
|
||||||
color: color,
|
|
||||||
options: options
|
|
||||||
}
|
|
||||||
console.log(data)
|
|
||||||
createGame(data)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,7 @@ import * as status from "../../net/status.js"
|
||||||
// import {joinGame, createGame} from "../../net/netcode.js"
|
// import {joinGame, createGame} from "../../net/netcode.js"
|
||||||
import { changeScene } from "../scene.js"
|
import { changeScene } from "../scene.js"
|
||||||
import * as createMenu from "./create.js"
|
import * as createMenu from "./create.js"
|
||||||
|
import {ID} from "../../util.js"
|
||||||
function ID(id) {
|
|
||||||
return document.getElementById(id)
|
|
||||||
}
|
|
||||||
|
|
||||||
const joinType = ID("joinType")
|
const joinType = ID("joinType")
|
||||||
const joinGameMenu = ID("joinGame")
|
const joinGameMenu = ID("joinGame")
|
||||||
|
|
|
@ -3,7 +3,7 @@ import * as status from "./status.js"
|
||||||
import {game} from "../game/game.js"
|
import {game} from "../game/game.js"
|
||||||
import {render} from "../display/draw.js"
|
import {render} from "../display/draw.js"
|
||||||
import { changeScene } from "../interface/scene.js"
|
import { changeScene } from "../interface/scene.js"
|
||||||
import { illegalAction } from "../interface/common/illegalaction.js"
|
import { illegalAction } from "../illegalaction.js"
|
||||||
|
|
||||||
export var socket = io.connect(env.IP_ADDRESS);
|
export var socket = io.connect(env.IP_ADDRESS);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,8 @@ export class World {
|
||||||
this.data = placer.place(x, y, this.data)
|
this.data = placer.place(x, y, this.data)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.generate(x, y).mark();
|
this.generate(x, y)
|
||||||
|
this.mark()
|
||||||
this.data = placer.place(x, y, this.data)
|
this.data = placer.place(x, y, this.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue