init
BIN
tardisproject/assets/arrow-left.png
Executable file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
tardisproject/assets/arrow-right.png
Executable file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
tardisproject/assets/button-back-red.png
Executable file
|
After Width: | Height: | Size: 9.3 KiB |
BIN
tardisproject/assets/button-back-white.png
Executable file
|
After Width: | Height: | Size: 9.7 KiB |
BIN
tardisproject/assets/button-back.png
Executable file
|
After Width: | Height: | Size: 34 KiB |
BIN
tardisproject/assets/button.png
Executable file
|
After Width: | Height: | Size: 100 KiB |
BIN
tardisproject/assets/lever-back.png
Executable file
|
After Width: | Height: | Size: 15 KiB |
BIN
tardisproject/assets/lever-forward.png
Executable file
|
After Width: | Height: | Size: 15 KiB |
BIN
tardisproject/assets/lever-left.png
Executable file
|
After Width: | Height: | Size: 18 KiB |
BIN
tardisproject/assets/lever-mobile-buttons.png
Executable file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
tardisproject/assets/lever-right.pdn
Executable file
BIN
tardisproject/assets/lever-right.png
Executable file
|
After Width: | Height: | Size: 17 KiB |
BIN
tardisproject/assets/lever.png
Executable file
|
After Width: | Height: | Size: 12 KiB |
BIN
tardisproject/assets/panel.png
Executable file
|
After Width: | Height: | Size: 38 KiB |
BIN
tardisproject/assets/switch-down.png
Executable file
|
After Width: | Height: | Size: 9.5 KiB |
BIN
tardisproject/assets/switch-up.png
Executable file
|
After Width: | Height: | Size: 8.7 KiB |
BIN
tardisproject/assets/switch.png
Executable file
|
After Width: | Height: | Size: 8.2 KiB |
BIN
tardisproject/assets/text-panel.png
Executable file
|
After Width: | Height: | Size: 8.5 KiB |
BIN
tardisproject/assets/throttle-lever-base.png
Executable file
|
After Width: | Height: | Size: 9.0 KiB |
BIN
tardisproject/assets/throttle-lever-handle.png
Executable file
|
After Width: | Height: | Size: 2.3 KiB |
372
tardisproject/classes.js
Executable file
@@ -0,0 +1,372 @@
|
||||
class Panel{
|
||||
constructor(x,y,width,height){
|
||||
this.width=width;
|
||||
this.height=height;
|
||||
this.pos={
|
||||
x: x,
|
||||
y: y
|
||||
};
|
||||
}
|
||||
draw(){
|
||||
ctx.drawImage($("#img_panel")[0],this.pos.x,this.pos.y,this.width,this.height);
|
||||
}
|
||||
}
|
||||
class Throttlelever{
|
||||
constructor(panel,x,y,scale){
|
||||
this.panel=panel;
|
||||
this.scale=scale;
|
||||
this.name="throttle lever";
|
||||
this.desc="changes the power when teleporting";
|
||||
this.handlescale=scale*1.6;
|
||||
this.pos={
|
||||
x: setwidth/2-this.scale/2+x,
|
||||
y: setheight/2-this.scale/2+y
|
||||
};
|
||||
this.min=(this.pos.y-(this.scale+80)/5).toFixed(2);
|
||||
this.max=(this.pos.y+(this.scale+80)/2.4).toFixed(2);
|
||||
this.handlepos={
|
||||
x: setwidth/2-this.handlescale/2+x,
|
||||
y: this.max
|
||||
}
|
||||
this.mouseisdown=false;
|
||||
this.mouseisover=false;
|
||||
}
|
||||
draw(){
|
||||
if(panelnum==this.panel){
|
||||
if(this.handlepos.y<this.min){
|
||||
this.handlepos.y=this.min
|
||||
}
|
||||
if(this.handlepos.y>this.max){
|
||||
this.handlepos.y=this.max;
|
||||
}
|
||||
if(power.ison==false){
|
||||
this.handlepos.y=this.max
|
||||
}
|
||||
this.value=100-(((this.handlepos.y-this.pos.y+26).toFixed())/80*100).toFixed();
|
||||
ctx.drawImage($("#img_throttle_base")[0],this.pos.x,this.pos.y,this.scale,this.scale+80);
|
||||
ctx.drawImage($("#img_throttle_handle")[0],this.handlepos.x,this.handlepos.y,this.handlescale,this.handlescale+20);
|
||||
if(power.ison==true){
|
||||
ctx.fillStyle = "#0df";
|
||||
ctx.font = "13px Ariel";
|
||||
ctx.fillText(this.value,this.pos.x+15,this.pos.y+this.scale+72)
|
||||
}
|
||||
if(telepathicChover.ison==true&&this.mouseisover==true){
|
||||
ctx.fillStyle = "#000";
|
||||
ctx.globalAlpha = 0.8;
|
||||
ctx.fillRect(globalcx,globalcy,150,100)
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.font = "15px Ariel";
|
||||
ctx.fillStyle = "#fff";
|
||||
ctx.fillText(this.name,globalcx+20,globalcy+20,149)
|
||||
ctx.font = "12px Ariel";
|
||||
ctx.fillText(this.desc,globalcx,globalcy+40,149)
|
||||
}
|
||||
}
|
||||
}
|
||||
mouseon(cx,cy){
|
||||
if(panelnum==this.panel){
|
||||
if(cx>this.pos.x&&cx<this.pos.x+this.scale&&cy>this.pos.y&&cy<this.pos.y+this.scale+80){
|
||||
this.mouseisdown=true;
|
||||
this.handlepos.y=cy-this.handlescale/2;
|
||||
}
|
||||
}
|
||||
}
|
||||
move(cx,cy){
|
||||
if(panelnum==this.panel){
|
||||
if(cx>this.pos.x&&cx<this.pos.x+this.scale&&cy>this.pos.y&&cy<this.pos.y+this.scale+80){
|
||||
if(this.mouseisdown==true){
|
||||
this.handlepos.y=cy-this.handlescale/2;
|
||||
}
|
||||
this.mouseisover=true;
|
||||
} else {
|
||||
this.mouseisover=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
class Button{
|
||||
constructor(panel,x,y,scale,Back,offNoPower,redOff,redNoPower,name,desc){
|
||||
this.panel=panel;
|
||||
this.scale=scale;
|
||||
this.name=name;
|
||||
this.desc=desc;
|
||||
this.pos={
|
||||
x: setwidth/2-this.scale/2+x,
|
||||
y: setheight/2-this.scale/2+y
|
||||
};
|
||||
this.ison=false;
|
||||
this.back=Back;
|
||||
this.redOff=redOff;
|
||||
this.offNoPower=offNoPower;
|
||||
this.redNoPower=redNoPower;
|
||||
this.mouseisover=false;
|
||||
this.locked=false;
|
||||
this.run_function=false;
|
||||
}
|
||||
draw(){
|
||||
if(power.ison==false&&this.offNoPower==true){
|
||||
this.ison=false;
|
||||
}
|
||||
if(panelnum==this.panel){
|
||||
if(this.ison==true&&this.back==true){
|
||||
ctx.drawImage($("#img_button_back")[0],this.pos.x,this.pos.y,this.scale,this.scale);
|
||||
} else if(this.redNoPower==true&&power.ison==false){
|
||||
ctx.drawImage($("#img_button_back_red")[0],this.pos.x,this.pos.y,this.scale,this.scale);
|
||||
} else if(this.ison==false&&this.redOff==false){
|
||||
ctx.drawImage($("#img_button_back_white")[0],this.pos.x,this.pos.y,this.scale,this.scale);
|
||||
} else if(this.ison==false&&this.redOff==true){
|
||||
ctx.drawImage($("#img_button_back_red")[0],this.pos.x,this.pos.y,this.scale,this.scale);
|
||||
}
|
||||
ctx.drawImage($("#img_button")[0],this.pos.x,this.pos.y,this.scale,this.scale);
|
||||
}
|
||||
}
|
||||
drawhover(){
|
||||
if(telepathicChover.ison==true&&this.mouseisover==true){
|
||||
ctx.fillStyle = "#000";
|
||||
ctx.globalAlpha = 0.8;
|
||||
ctx.fillRect(globalcx,globalcy,150,120)
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.font = "15px Ariel";
|
||||
ctx.fillStyle = "#fff";
|
||||
ctx.fillText(this.name,globalcx+20,globalcy+20,120)
|
||||
ctx.font = "12px Ariel";
|
||||
ctx.fillText(this.desc,globalcx,globalcy+40,120)
|
||||
}
|
||||
}
|
||||
toggle(cx,cy,run_function){
|
||||
if(panelnum==this.panel){
|
||||
if(cx>this.pos.x&&cx<this.pos.x+this.scale&&cy>this.pos.y&&cy<this.pos.y+this.scale){
|
||||
if(this.locked==false){
|
||||
this.run_function=run_function;
|
||||
switch(this.ison){
|
||||
case false:
|
||||
this.ison = true;
|
||||
break;
|
||||
case true:
|
||||
this.ison = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
move(cx,cy){
|
||||
if(panelnum==this.panel&&cx>this.pos.x&&cx<this.pos.x+this.scale&&cy>this.pos.y&&cy<this.pos.y+this.scale){
|
||||
this.mouseisover=true;
|
||||
} else {
|
||||
this.mouseisover=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
class Switch{
|
||||
constructor(panel,x,y,scale,offNoPower,is3stage,name,desc){
|
||||
this.panel=panel;
|
||||
this.scale=scale;
|
||||
this.name=name;
|
||||
this.desc=desc;
|
||||
this.pos={
|
||||
x: setwidth/2-this.scale/2+x,
|
||||
y: setheight/2-this.scale/2+y
|
||||
};
|
||||
this.stage=2;
|
||||
this.ison=false;
|
||||
this.offNoPower=offNoPower;
|
||||
this.is3stage=is3stage;
|
||||
this.mouseisover=false;
|
||||
}
|
||||
draw(){
|
||||
if(power.ison==false&&this.offNoPower==true){
|
||||
this.stage=2;
|
||||
this.ison=false;
|
||||
}
|
||||
if(panelnum==this.panel){
|
||||
if(this.stage==1){
|
||||
this.ison=true;
|
||||
ctx.drawImage($("#img_switch_down")[0],this.pos.x,this.pos.y,this.scale,this.scale);
|
||||
}
|
||||
if(this.stage==2){
|
||||
this.ison=false;
|
||||
ctx.drawImage($("#img_switch")[0],this.pos.x,this.pos.y,this.scale,this.scale);
|
||||
}
|
||||
if(this.stage==3){
|
||||
this.ison=true;
|
||||
ctx.drawImage($("#img_switch_up")[0],this.pos.x,this.pos.y,this.scale,this.scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
drawhover(){
|
||||
if(telepathicChover.ison==true&&this.mouseisover==true){
|
||||
ctx.fillStyle = "#000";
|
||||
ctx.globalAlpha = 0.8;
|
||||
ctx.fillRect(globalcx,globalcy,150,100)
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.font = "15px Ariel";
|
||||
ctx.fillStyle = "#fff";
|
||||
ctx.fillText(this.name,globalcx+20,globalcy+20,this.pos.y+this.scale)
|
||||
ctx.font = "12px Ariel";
|
||||
ctx.fillText(this.desc,globalcx,globalcy+40,this.pos.y+this.scale)
|
||||
}
|
||||
}
|
||||
toggle(cx,cy){
|
||||
if(panelnum==this.panel){
|
||||
if(this.is3stage==false){
|
||||
if(cx>this.pos.x&&cx<this.pos.x+this.scale&&cy>this.pos.y&&cy<this.pos.y+this.scale){
|
||||
switch(this.stage){
|
||||
case 2:
|
||||
this.stage=3;
|
||||
break;
|
||||
case 3:
|
||||
this.stage=2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(cx>this.pos.x&&cx<this.pos.x+this.scale){
|
||||
if(cy>this.pos.y&&cy<this.pos.y+(this.scale/3)){
|
||||
this.stage=3;
|
||||
}
|
||||
if(cy>this.pos.y+(this.scale/3)&&cy<this.pos.y+(this.scale/3*2)){
|
||||
this.stage=2;
|
||||
}
|
||||
if(cy>this.pos.y+(this.scale/3*2)&&cy<this.pos.y+this.scale){
|
||||
this.stage=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
move(cx,cy){
|
||||
if(panelnum==this.panel&&cx>this.pos.x&&cx<this.pos.x+this.scale&&cy>this.pos.y&&cy<this.pos.y+this.scale){
|
||||
this.mouseisover=true;
|
||||
} else {
|
||||
this.mouseisover=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
class Arrowbutton{
|
||||
constructor(x,y,width,height){
|
||||
this.width=width;
|
||||
this.height=height;
|
||||
this.pos={
|
||||
x: x,
|
||||
y: y
|
||||
};
|
||||
}
|
||||
draw(name){
|
||||
ctx.drawImage($(name)[0],this.pos.x,this.pos.y,this.width,this.height);
|
||||
}
|
||||
click(cx,cy,type){
|
||||
if(cx>this.pos.x&&cx<this.pos.x+this.width&&cy>this.pos.y&&cy<this.pos.y+this.height){
|
||||
if(type=="up"){
|
||||
panelnum++;
|
||||
if(panelnum>4)panelnum=1;
|
||||
}
|
||||
if(type=="down"){
|
||||
panelnum--;
|
||||
if(panelnum<1)panelnum=4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
class Flever{
|
||||
constructor(panel,x,y,scale){
|
||||
this.panel=panel;
|
||||
this.state="#img_flever";
|
||||
this.scale=-120;
|
||||
this.name="flight lever"
|
||||
this.desc="allows you to move when flightmode is enabled"
|
||||
this.pos={
|
||||
x: setwidth/2-(this.scale+260)/2+x,
|
||||
y: setheight/2-(this.scale+409)/2+y
|
||||
};
|
||||
this.buttonpos={
|
||||
x: ((this.pos.x+(this.scale+260)/2)-(this.scale+239)/2)+6,
|
||||
y: this.pos.y+(this.scale+409)-90
|
||||
}
|
||||
this.mouseisover=false;
|
||||
this.mobilebuttons=false;
|
||||
}
|
||||
draw(){
|
||||
if(panelnum==this.panel){
|
||||
ctx.drawImage($(this.state)[0],this.pos.x,this.pos.y,this.scale+260,this.scale+409);
|
||||
if(this.mobilebuttons==true){
|
||||
ctx.drawImage($("#img_flever_mobile")[0],this.buttonpos.x,this.buttonpos.y,this.scale+239,this.scale+191);
|
||||
}
|
||||
}
|
||||
}
|
||||
drawhover(){
|
||||
if(telepathicChover.ison==true&&this.mouseisover==true){
|
||||
ctx.fillStyle = "#000";
|
||||
ctx.globalAlpha = 0.8;
|
||||
ctx.fillRect(globalcx,globalcy,160,100)
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.font = "15px Ariel";
|
||||
ctx.fillStyle = "#fff";
|
||||
ctx.fillText(this.name,globalcx+20,globalcy+20,this.pos.y+this.scale)
|
||||
ctx.font = "12px Ariel";
|
||||
ctx.fillText(this.desc,globalcx,globalcy+40,this.pos.y+this.scale+20)
|
||||
ctx.fillText("use arrow keys on keyboard",globalcx,globalcy+80,this.pos.y+this.scale)
|
||||
}
|
||||
}
|
||||
toggle(cx,cy){
|
||||
if(panelnum==this.panel&&cx>this.pos.x&&cx<this.pos.x+this.scale+260&&cy>this.pos.y&&cy<this.pos.y+this.scale+409){
|
||||
if(this.mobilebuttons==true){
|
||||
if(cx>((this.buttonpos.x)+6)+(this.scale+227)/3&&cy>this.buttonpos.y&&cx<(((this.buttonpos.x)+6)+(this.scale+227)/3)+(this.scale+227)/3&&cy<this.buttonpos.y+(this.scale+191)/2){
|
||||
this.state="#img_flever_forward";
|
||||
}
|
||||
else if(cx>((this.buttonpos.x)+6)+(this.scale+227)/3&&cy>this.buttonpos.y+(this.scale+155)&&cx<(((this.buttonpos.x)+6)+(this.scale+227)/3)+(this.scale+227)/3&&cy<this.buttonpos.y+(this.scale+155)+(this.scale+191)/2){
|
||||
this.state="#img_flever_back";
|
||||
}
|
||||
else if(cx>((this.buttonpos.x)+6)&&cy>this.buttonpos.y+(this.scale+155)&&cx<(((this.buttonpos.x)+6)+(this.scale+227)/3)+(this.scale+227)/3&&cy<this.buttonpos.y+(this.scale+155)+(this.scale+191)/2){
|
||||
this.state="#img_flever_left";
|
||||
}
|
||||
else if(cx>((this.buttonpos.x)+6)+(this.scale+227)/1.5&&cy>this.buttonpos.y+(this.scale+155)&&cy<this.buttonpos.y+(this.scale+155)+(this.scale+191)/2){
|
||||
this.state="#img_flever_right";
|
||||
} else {
|
||||
this.state="#img_flever";
|
||||
}
|
||||
}
|
||||
this.mobilebuttons=true;
|
||||
}
|
||||
}
|
||||
move(cx,cy){
|
||||
if(panelnum==this.panel&&cx>this.pos.x&&cx<this.pos.x+this.scale+260&&cy>this.pos.y&&cy<this.pos.y+this.scale+409){
|
||||
this.mouseisover=true;
|
||||
} else {
|
||||
this.mouseisover=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
class Textpanel{
|
||||
constructor(panel,x,y,width,height){
|
||||
this.panel=panel;
|
||||
this.width=width;
|
||||
this.height=height;
|
||||
this.pos={
|
||||
x: setwidth/2-this.width/2+x,
|
||||
y: setheight/2-this.height/2+y
|
||||
};
|
||||
this.text="";
|
||||
}
|
||||
draw(){
|
||||
if(panelnum==this.panel){
|
||||
ctx.drawImage($("#img_text_panel")[0],this.pos.x,this.pos.y,this.width,this.height);
|
||||
this.text=this.text.toString().split("BR");
|
||||
ctx.fillStyle = "#0df";
|
||||
if(this.text.length>1){
|
||||
var size=(this.height/1.8-0.5)/(this.text.length-0.5);
|
||||
} else {
|
||||
var size=(this.height/1.8-0.5)/1;
|
||||
}
|
||||
ctx.font = size+"px Ariel";
|
||||
if(power.ison==true){
|
||||
for(var i=0; i<this.text.length; i++){
|
||||
ctx.fillText(this.text[i],this.pos.x+this.width/12,this.pos.y+this.height/this.text.length*(i+1-0.3),this.width/1.21);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//scanner
|
||||
|
||||
26
tardisproject/planetdata.json
Executable file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"earth":{
|
||||
"cords":"0/0/0",
|
||||
"scale":"500",
|
||||
"generateRandomObjects":"true",
|
||||
"objects":{
|
||||
"refuel":[
|
||||
"0/1",
|
||||
"20/20"
|
||||
],
|
||||
"space-radio":[
|
||||
"3/3"
|
||||
]
|
||||
}
|
||||
},
|
||||
"earthsMoon":{
|
||||
"cords":"1/0/0",
|
||||
"scale":"100",
|
||||
"generateRandomObjects":"false",
|
||||
"objects":{
|
||||
"space-radio":[
|
||||
"1/0"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
450
tardisproject/testing??.php
Executable file
@@ -0,0 +1,450 @@
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
*{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
background-color: rgb(50,50,50);
|
||||
}
|
||||
::-webkit-scrollbar {
|
||||
width: 0px; /* Remove scrollbar space */
|
||||
background: transparent; /* Optional: just make scrollbar invisible */
|
||||
}
|
||||
img{
|
||||
display: none;
|
||||
background: transparent;
|
||||
}
|
||||
#Gscreen{
|
||||
border: 1px solid black;
|
||||
}
|
||||
.Gscreen-container{
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
a{
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 10px;
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
<img id="img_button" src="assets/button.png">
|
||||
<img id="img_button_back" src="assets/button-back.png">
|
||||
<img id="img_button_back_white" src="assets/button-back-white.png">
|
||||
<img id="img_button_back_red" src="assets/button-back-red.png">
|
||||
<img id="img_panel" src="assets/panel.png">
|
||||
<img id="img_flever" src="assets/lever.png">
|
||||
<img id="img_flever_left" src="assets/lever-left.png">
|
||||
<img id="img_flever_right" src="assets/lever-right.png">
|
||||
<img id="img_flever_forward" src="assets/lever-forward.png">
|
||||
<img id="img_flever_back" src="assets/lever-back.png">
|
||||
<img id="img_flever_mobile" src="assets/lever-mobile-buttons.png">
|
||||
<img id="img_text_panel" src="assets/text-panel.png">
|
||||
<img id="img_arrow_left" src="assets/arrow-left.png">
|
||||
<img id="img_arrow_right" src="assets/arrow-right.png">
|
||||
<img id="img_switch" src="assets/switch.png">
|
||||
<img id="img_switch_up" src="assets/switch-up.png">
|
||||
<img id="img_switch_down" src="assets/switch-down.png">
|
||||
<img id="img_throttle_base" src="assets/throttle-lever-base.png">
|
||||
<img id="img_throttle_handle" src="assets/throttle-lever-handle.png">
|
||||
</head>
|
||||
<body>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
|
||||
<div class="Gscreen-container"><canvas id="Gscreen" width=1000px height=600px></canvas></div>
|
||||
<a href="../index.html">go home</a>
|
||||
|
||||
<script src="classes.js"></script>
|
||||
<script language="javascript" type="text/javascript">
|
||||
let scrn=document.getElementById('Gscreen');
|
||||
let ctx=scrn.getContext('2d');
|
||||
function locked_game_loop_wrap(loop){
|
||||
|
||||
//settings & defaults
|
||||
setwidth=1000;
|
||||
setheight=600;
|
||||
let currfuel=100;
|
||||
let currplanet=[0,0,0];
|
||||
let currcords=[0,0];
|
||||
let destcords=[[0,0,0],[0,0]]
|
||||
panelnum=2;
|
||||
let tardis_move_status="idle";
|
||||
let flightloop_isrunning=false;
|
||||
|
||||
//scanner class, had to define here because of scope
|
||||
class TelepathicScanner{
|
||||
constructor(x,y,scale){
|
||||
this.width=scale;
|
||||
this.height=scale;
|
||||
this.pos={
|
||||
x: setwidth/2-this.width/2+x,
|
||||
y: setheight/2-this.height/2+y
|
||||
};
|
||||
}
|
||||
draw(){
|
||||
if(power.ison==true){
|
||||
this.text=scannertext().split("BR")
|
||||
ctx.font = "20px Ariel";
|
||||
ctx.fillStyle = "#000"
|
||||
ctx.globalAlpha = 0.5;
|
||||
ctx.fillRect(this.pos.x,this.pos.y,this.width-30,this.height-13)
|
||||
ctx.fillStyle = "#fff";
|
||||
ctx.globalAlpha = 1;
|
||||
for(var i=0; i<this.text.length; i++){
|
||||
ctx.fillText(this.text[i],this.pos.x+2,this.pos.y+this.height/this.text.length*(i+1),this.width/1.21);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let planetdata={};
|
||||
//error cheak and auto sets
|
||||
$.getJSON("planetdata.json", function(result){
|
||||
planetdata=result;
|
||||
})
|
||||
.error(function(){
|
||||
if(alert('error loading planet data')){
|
||||
location.reload();
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
//side loops
|
||||
function moveloop(){
|
||||
tardis_move_status="flying";
|
||||
insideloop();
|
||||
idlefuelloop();
|
||||
function insideloop(){
|
||||
if(fmbutton.ison==true){
|
||||
if(flever.state=="#img_flever_forward"){
|
||||
currcords[1]++
|
||||
}
|
||||
if(flever.state=="#img_flever_back"){
|
||||
currcords[1]--
|
||||
}
|
||||
if(flever.state=="#img_flever_left"){
|
||||
currcords[0]--
|
||||
}
|
||||
if(flever.state=="#img_flever_right"){
|
||||
currcords[0]++
|
||||
}
|
||||
setTimeout(insideloop,500)
|
||||
} else {
|
||||
if(takeoffbutton.ison==false){
|
||||
tardis_move_status="idle";
|
||||
}
|
||||
}
|
||||
}
|
||||
function idlefuelloop(){
|
||||
if(fmbutton.ison==true){
|
||||
currfuel--
|
||||
setTimeout(idlefuelloop,3000)
|
||||
}
|
||||
}
|
||||
}
|
||||
function flightloop(){
|
||||
if(flightloop_isrunning==false){
|
||||
flightloop_isrunning=true;
|
||||
fmbutton.ison=false;
|
||||
fmbutton.locked=true;
|
||||
takeoffbutton.locked=true;
|
||||
tardis_move_status="taking off";
|
||||
setTimeout(function(){
|
||||
tardis_move_status="in vortex";
|
||||
takeoffbutton.locked=false;
|
||||
currplanet=destcords[0];
|
||||
currcords=destcords[1];
|
||||
flightloop_idlefuelloop();
|
||||
flightloop_waitforoff();
|
||||
},3000)
|
||||
function flightloop_idlefuelloop(){
|
||||
if(takeoffbutton.ison==true){
|
||||
currfuel--;
|
||||
setTimeout(flightloop_idlefuelloop,15000);
|
||||
}
|
||||
}
|
||||
function flightloop_waitforoff(){
|
||||
if(takeoffbutton.ison==false){
|
||||
takeoffbutton.locked=true;
|
||||
tardis_move_status="landing";
|
||||
currplanet=destcords[0];
|
||||
currcords=destcords[1];
|
||||
setTimeout(function(){
|
||||
tardis_move_status="idle";
|
||||
takeoffbutton.locked=false;
|
||||
fmbutton.locked=false;
|
||||
flightloop_isrunning=false;
|
||||
},3000);
|
||||
} else {
|
||||
setTimeout(flightloop_waitforoff,500);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function textentryT_runcommands(){
|
||||
if(textEntryButton.ison==false){
|
||||
let text=textEntryT.text.toString().split(" ")
|
||||
if(text[0]=="setdest:"){
|
||||
destcords=[[parseInt(text[1]),parseInt(text[2]),parseInt(text[3])],[parseInt(text[4]),parseInt(text[5])]];
|
||||
}
|
||||
textEntryT.text="";
|
||||
textEntryButton.ison=false;
|
||||
} else {
|
||||
if(document.getElementById("entry_box_mobile").value!==""){
|
||||
textEntryT.text=document.getElementById("entry_box_mobile").value;
|
||||
document.getElementById("entry_box_mobile").value="";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
button syntax
|
||||
panel, x, y, scale, back when on, off when no power, red when off, red when no power, name, desc
|
||||
switch syntax
|
||||
panel, x, y, scale, off when no power, 3 stage button?
|
||||
*/
|
||||
let arrowleft = new Arrowbutton(1,setheight/2-70/2,70,70);
|
||||
let arrowright = new Arrowbutton(1000-70-1,setheight/2-70/2,70,70);
|
||||
let panel = new Panel(0,150,1000,450);
|
||||
telepathicScanner = new TelepathicScanner(10,-150,200);
|
||||
//panel 2 --space
|
||||
power = new Switch(2,180,200,70,false,false,"power","enables the power....");
|
||||
let fmbutton = new Button(2,240,200,50,true,true,false,true,"flightmode button","enables flightmode for moving");
|
||||
let flever = new Flever(2,320,100);
|
||||
let flightTpanel = new Textpanel(2,0,0,190,80);
|
||||
//panel 3 --flight
|
||||
let throttlelever = new Throttlelever(3,290,140,50);
|
||||
let telepathicCmain = new Switch(3,-180,-40,50,true,false,"telepathic main","enables main telepath functions");
|
||||
let telepathicCscanner = new Switch(3,-140,-40,50,true,false,"telepathic scanner","enables telepathic scanner");
|
||||
telepathicChover = new Switch(3,-100,-40,50,true,false,"telepathic hover","what you are reading right now");
|
||||
let takeoffbutton= new Button(3,220,220,50,true,true,false,true,"takeoffbutton","for teleporting");
|
||||
let flightTpanel2 = new Textpanel(3,0,0,120,130);
|
||||
let textEntryT = new Textpanel(3,-240,220,100,30);
|
||||
let textEntryButton = new Button(3,-160,220,30,true,true,false,true,"text enable","allows you to use commands (keyboard)")
|
||||
let text_status = new Textpanel(3,135,-30,140,45);
|
||||
|
||||
|
||||
|
||||
window.onload = function() {
|
||||
|
||||
//gameloop
|
||||
function gameloop(){
|
||||
if(currfuel<0)currfuel=0;
|
||||
if(currfuel>100)currfuel=100;
|
||||
if(currfuel<1){
|
||||
fmbutton.ison=false;
|
||||
}
|
||||
//cord updater
|
||||
for(var planet in planetdata){
|
||||
planetcords=planetdata[planet].cords.split("/")
|
||||
planetcords=[parseInt(planetcords[0]),parseInt(planetcords[1]),parseInt(planetcords[2])]
|
||||
if(currplanet[0]==planetcords[0]&&currplanet[1]==planetcords[1]&&currplanet[2]==planetcords[2]){
|
||||
//get and set based limits
|
||||
if(currcords[0]>parseInt(planetdata[planet].scale)){currcords[0]=-parseInt(planetdata[planet].scale)}
|
||||
if(currcords[1]>parseInt(planetdata[planet].scale)){currcords[1]=-parseInt(planetdata[planet].scale)}
|
||||
if(currcords[0]<-parseInt(planetdata[planet].scale)){currcords[0]=parseInt(planetdata[planet].scale)}
|
||||
if(currcords[1]<-parseInt(planetdata[planet].scale)){currcords[1]=parseInt(planetdata[planet].scale)}
|
||||
|
||||
//asd
|
||||
for(var objects in planetdata[planet].objects){
|
||||
for(var ListOfObjects in planetdata[planet].objects[objects]){
|
||||
LOOcords=planetdata[planet].objects[objects][ListOfObjects].split("/")
|
||||
LOOcords=[parseInt(LOOcords[0]),parseInt(LOOcords[1])]
|
||||
if(currcords[0]==LOOcords[0]&&currcords[1]==LOOcords[1]){
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//main drawing
|
||||
ctx.clearRect(0,0,setwidth,setheight);
|
||||
panel.draw();
|
||||
arrowleft.draw("#img_arrow_left");
|
||||
arrowright.draw("#img_arrow_right");
|
||||
//panel 2
|
||||
flightTpanel.text="planet x:"+currplanet[0]+" y:"+currplanet[1]+" z:"+currplanet[2]+"BRx:"+currcords[0]+" y:"+currcords[1]+"BRfuel: "+currfuel;
|
||||
flightTpanel.draw();
|
||||
power.draw();
|
||||
fmbutton.draw();
|
||||
flever.draw();
|
||||
//panel3
|
||||
throttlelever.draw();
|
||||
telepathicCmain.draw();
|
||||
telepathicCscanner.draw();
|
||||
telepathicChover.draw();
|
||||
takeoffbutton.draw();
|
||||
flightTpanel2.text="Current-"+
|
||||
"BRspace: "+currplanet[0]+" "+currplanet[1]+" "+currplanet[2]+"BRplanet: "+currcords[0]+" "+currcords[1]+
|
||||
"BRDestination-"+
|
||||
"BRspace: "+destcords[0][0]+" "+destcords[0][1]+" "+destcords[0][2]+"BRplanet: "+destcords[1][0]+" "+destcords[1][1];
|
||||
flightTpanel2.draw();
|
||||
textEntryButton.draw();
|
||||
textEntryT.draw();
|
||||
text_status.draw();
|
||||
text_status.text="status: "+tardis_move_status;
|
||||
|
||||
if(telepathicCmain.ison==false){
|
||||
telepathicCscanner.stage=2;
|
||||
telepathicChover.stage=2;
|
||||
}
|
||||
if(telepathicCscanner.ison==true){
|
||||
telepathicScanner.draw();
|
||||
}
|
||||
//draw hovers
|
||||
fmbutton.drawhover();
|
||||
power.drawhover();
|
||||
flever.drawhover();
|
||||
telepathicCmain.drawhover();
|
||||
telepathicCscanner.drawhover();
|
||||
telepathicChover.drawhover();
|
||||
takeoffbutton.drawhover();
|
||||
textEntryButton.drawhover();
|
||||
requestAnimationFrame(gameloop);
|
||||
}
|
||||
gameloop();
|
||||
|
||||
|
||||
|
||||
//!---mouse and button
|
||||
scrn.addEventListener('mousedown',function(event){
|
||||
var cx = event.pageX - $('#Gscreen').offset().left;
|
||||
var cy = event.pageY - $('#Gscreen').offset().top;
|
||||
arrowleft.click(cx,cy,"down");
|
||||
arrowright.click(cx,cy,"up");
|
||||
//panel 2
|
||||
fmbutton.toggle(cx,cy,true);
|
||||
if(fmbutton.run_function==true){moveloop();fmbutton.run_function=false;}
|
||||
power.toggle(cx,cy,false);
|
||||
flever.toggle(cx,cy);
|
||||
if(fmbutton.ison==false){flever.mobilebuttons=false}
|
||||
//panel3
|
||||
throttlelever.mouseon(cx,cy);
|
||||
telepathicCmain.toggle(cx,cy);
|
||||
telepathicCscanner.toggle(cx,cy);
|
||||
telepathicChover.toggle(cx,cy);
|
||||
takeoffbutton.toggle(cx,cy,true);
|
||||
if(takeoffbutton.run_function==true){flightloop();takeoffbutton.run_function=false;}
|
||||
textEntryButton.toggle(cx,cy,true);
|
||||
if(textEntryButton.run_function==true){textentryT_runcommands();textEntryButton.run_function=false;}
|
||||
},false);
|
||||
scrn.addEventListener('mouseup',function(event){
|
||||
throttlelever.mouseisdown=false;
|
||||
},false);
|
||||
scrn.addEventListener('mousemove',function(event){
|
||||
var cx = event.pageX - $('#Gscreen').offset().left;
|
||||
var cy = event.pageY - $('#Gscreen').offset().top;
|
||||
globalcx = event.pageX - $('#Gscreen').offset().left;
|
||||
globalcy = event.pageY - $('#Gscreen').offset().top;
|
||||
//panel 3
|
||||
throttlelever.move(cx,cy);
|
||||
fmbutton.move(cx,cy);
|
||||
power.move(cx,cy);
|
||||
flever.move(cx,cy);
|
||||
telepathicCmain.move(cx,cy);
|
||||
telepathicCscanner.move(cx,cy);
|
||||
telepathicChover.move(cx,cy);
|
||||
takeoffbutton.move(cx,cy);
|
||||
textEntryButton.move(cx,cy);
|
||||
},false);
|
||||
document.addEventListener('keydown',function(event){
|
||||
if(textEntryButton.ison==true){
|
||||
if(event.keyCode==13){
|
||||
textEntryButton.ison=false;
|
||||
textentryT_runcommands();
|
||||
} else if(event.keyCode==16){
|
||||
|
||||
} else if(event.keyCode==8){
|
||||
textEntryT.text=textEntryT.text.toString().substring(0,textEntryT.text.toString().length-1);
|
||||
} else if(event.keyCode==32){
|
||||
textEntryT.text=textEntryT.text+" ";
|
||||
} else {
|
||||
textEntryT.text=textEntryT.text+event.key;
|
||||
}
|
||||
}
|
||||
if(fmbutton.ison==true){
|
||||
if(panelnum==2){
|
||||
if(event.keyCode==38){
|
||||
flever.state="#img_flever_forward";
|
||||
}
|
||||
if(event.keyCode==37){
|
||||
flever.state="#img_flever_left";
|
||||
}
|
||||
if(event.keyCode==39){
|
||||
flever.state="#img_flever_right";
|
||||
}
|
||||
if(event.keyCode==40){
|
||||
flever.state="#img_flever_back";
|
||||
}
|
||||
if(event.keyCode==70){
|
||||
alert('respects payed');
|
||||
}
|
||||
}
|
||||
}
|
||||
},false);
|
||||
document.addEventListener('keyup',function(event){
|
||||
flever.state="#img_flever";
|
||||
},false);
|
||||
}
|
||||
|
||||
//scanner text function
|
||||
function scannertext(){
|
||||
text="";
|
||||
for(var planet in planetdata){
|
||||
planetcords=planetdata[planet].cords.split("/")
|
||||
planetcords=[parseInt(planetcords[0]),parseInt(planetcords[1]),parseInt(planetcords[2])]
|
||||
if(currplanet[0]==planetcords[0]&&currplanet[1]==planetcords[1]&&currplanet[2]==planetcords[2]&&(tardis_move_status=="idle"|tardis_move_status=="flying")){
|
||||
getcords=[]
|
||||
for(var objects in planetdata[planet].objects){
|
||||
for(var ListOfObjects in planetdata[planet].objects[objects]){
|
||||
LOOcords=planetdata[planet].objects[objects][ListOfObjects].split("/")
|
||||
LOOcords=[parseInt(LOOcords[0]),parseInt(LOOcords[1])]
|
||||
if(objects=="refuel"){
|
||||
getcords.push([LOOcords[0],LOOcords[1],"木"])
|
||||
}
|
||||
if(objects=="space-radio"){
|
||||
getcords.push([LOOcords[0],LOOcords[1],"♖"])
|
||||
}
|
||||
}
|
||||
}
|
||||
for(var y=(currcords[1]+4);y>=(currcords[1]-4);y--){
|
||||
y2=y
|
||||
if(y2>parseInt(planetdata[planet].scale)){y2=-((parseInt(planetdata[planet].scale)*2+1)-y)}
|
||||
if(y2<-parseInt(planetdata[planet].scale)){y2=((parseInt(planetdata[planet].scale)*2+1)+y)}
|
||||
for(var x=(currcords[0]-4);x<=(currcords[0]+4);x++){
|
||||
x2=x
|
||||
if(x2>parseInt(planetdata[planet].scale)){x2=-((parseInt(planetdata[planet].scale)*2+1)-x)}
|
||||
if(x2<-parseInt(planetdata[planet].scale)){x2=((parseInt(planetdata[planet].scale)*2+1)+x)}
|
||||
for(i=0;i<getcords.length;i++){
|
||||
if(x2==getcords[i][0]&&y2==getcords[i][1]){
|
||||
texticon=getcords[i][2]
|
||||
break;
|
||||
} else if(x2==currcords[0]&&y2==currcords[1]){
|
||||
texticon="U"
|
||||
} else {
|
||||
texticon="+"
|
||||
}
|
||||
}
|
||||
text=text+"["+texticon+"]"
|
||||
}
|
||||
text=text+"BR"
|
||||
}
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
}
|
||||
locked_game_loop_wrap();
|
||||
</script>
|
||||
|
||||
<br><br>
|
||||
<div style="color: white;" align="center">
|
||||
<textarea id="entry_box_mobile" style="color: white; padding: 4px;"></textarea>
|
||||
<p>the box below allows mobile users to enter text to things one the game without having to
|
||||
plug in a keyboard</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||