Now Works as it did before all the rollup.

This commit is contained in:
Alexander Bass 2022-06-24 15:13:56 -04:00
parent d428eb3efe
commit 288108282f
7 changed files with 19 additions and 32 deletions

View file

@ -2,3 +2,4 @@ import './display/draw.js';
import './game/game.js'
import './interface/mainmenu/menu.js'
import './net/netcode.js'
import './interface/game/mouse.js'

View file

@ -1,5 +1,5 @@
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"
class Cursor {
@ -17,9 +17,8 @@ canvas.addEventListener('mousemove', e => {
mouseMoved(e)
});
canvas.addEventListener("mousedown", function(e)
{
getMousePosition(canvas, e);
canvas.addEventListener("mousedown", e => {
getMousePosition(e);
});
function mouseMoved(event) {
@ -35,7 +34,7 @@ function mouseMoved(event) {
}
}
function getMousePosition(canvas, event) {
function getMousePosition(event) {
const tileSize = game.tileSize
// Get mouse position on canvas
const rect = canvas.getBoundingClientRect();
@ -48,6 +47,6 @@ function getMousePosition(canvas, event) {
console.log("Click!")
console.log(xu,yu)
clickCanvas({tilePosition: [xu,yu], mode: button})
net.clickCanvas({tilePosition: [xu,yu], mode: button})
}

View file

@ -1,4 +1,4 @@
import {joinGame, createGame} from "../../net/netcode.js"
import * as net from "../../net/netcode.js"
import { changeScene } from "../scene.js"
import {Picker} from "./picker.js"
import {tileArray, menuArray} from "../../display/tileRenderer.js"
@ -15,7 +15,7 @@ export function init(){
}
ID("createRoomButton").addEventListener("click", e => {
create(e)
createGameClick(e)
});
const mineSlider = ID("createGameOptionsMinePercent")
@ -150,25 +150,14 @@ function updatePercentageLabel(percentage) {
}
function create(event) {
function createGameClick(event) {
const name = ID("createGameUsername").value
const mines = ID("createGameOptionsMines").value
const width = widthBox.value;
const height = heightBox.value;
const color = colorPicker.selected
const width = Number(widthBox.value);
const height = Number(heightBox.value);
const color = Number(colorPicker.selected);
if (name == '' || mines == '' || width == '' || height == '' || status.get() == 'disconnected') return
const options = {
mines: mines,
width: width,
height: height
}
const data =
{
name: name,
color: color,
options: options
}
console.log(data)
createGame(data)
const options = { mines: mines, width: width, height: height};
const data = {name: name, color: color, options: options};
net.createGame(data)
}

View file

@ -2,10 +2,7 @@ import * as status from "../../net/status.js"
// import {joinGame, createGame} from "../../net/netcode.js"
import { changeScene } from "../scene.js"
import * as createMenu from "./create.js"
function ID(id) {
return document.getElementById(id)
}
import {ID} from "../../util.js"
const joinType = ID("joinType")
const joinGameMenu = ID("joinGame")

View file

@ -3,7 +3,7 @@ import * as status from "./status.js"
import {game} from "../game/game.js"
import {render} from "../display/draw.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);

View file

@ -41,7 +41,8 @@ export class World {
this.data = placer.place(x, y, this.data)
}
} else {
this.generate(x, y).mark();
this.generate(x, y)
this.mark()
this.data = placer.place(x, y, this.data)
}