- add new sprites
- add 2D character option - new desciptive text
BIN
public/characterSprites/Blue/Down.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
public/characterSprites/Blue/Left.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
public/characterSprites/Blue/Right.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
public/characterSprites/Blue/Up.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
public/characterSprites/Orange/Down.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
public/characterSprites/Orange/Left.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
public/characterSprites/Orange/Right.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
public/characterSprites/Orange/Up.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
class Player extends Sprite {
|
class Player extends Sprite {
|
||||||
constructor({position,clickX,clickY,incrementX,incrementY,userId,username,skin,message,atPosition,animationColumn,imageSrc,frames,center,sprites}){
|
constructor({position,clickX,clickY,incrementX,incrementY,userId,username,skin,message,atPosition,isCharacter2D,animationColumn,imageSrc,frames,center,sprites}){
|
||||||
super({position,imageSrc,frames,center,atPosition,sprites,skin})
|
super({position,imageSrc,frames,center,atPosition,sprites,skin})
|
||||||
// super({imageSrc})
|
// super({imageSrc})
|
||||||
this.clickX = clickX
|
this.clickX = clickX
|
||||||
@ -10,6 +10,7 @@ class Player extends Sprite {
|
|||||||
this.incrementY = incrementY
|
this.incrementY = incrementY
|
||||||
this.userId = userId
|
this.userId = userId
|
||||||
this.username = username
|
this.username = username
|
||||||
|
this.isCharacter2D = isCharacter2D
|
||||||
this.message = message
|
this.message = message
|
||||||
this.messageSent = false
|
this.messageSent = false
|
||||||
|
|
||||||
@ -82,10 +83,18 @@ class Player extends Sprite {
|
|||||||
|
|
||||||
this.atPosition=false
|
this.atPosition=false
|
||||||
|
|
||||||
|
if(this.isCharacter2D){
|
||||||
|
// console.log(this.angleDeg)
|
||||||
|
if(90<this.angleDeg && this.angleDeg<270){this.image = this.Left}else{this.image = this.Right}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
if(225<this.angleDeg && this.angleDeg<315){this.image = this.Up}else
|
if(225<this.angleDeg && this.angleDeg<315){this.image = this.Up}else
|
||||||
if(45<this.angleDeg && this.angleDeg<135){this.image = this.Down}else
|
if(45<this.angleDeg && this.angleDeg<135){this.image = this.Down}else
|
||||||
if(135<this.angleDeg && this.angleDeg<225){this.image = this.Left}else{this.image = this.Right}
|
if(135<this.angleDeg && this.angleDeg<225){this.image = this.Left}else{this.image = this.Right}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
this.position.x+=this.incrementX;
|
this.position.x+=this.incrementX;
|
||||||
this.position.y+=this.incrementY;
|
this.position.y+=this.incrementY;
|
||||||
// console.log('goingtolocation')
|
// console.log('goingtolocation')
|
||||||
|
@ -23,7 +23,7 @@ of the container */
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
.loungeText ul{
|
.loungeText ul{
|
||||||
font-size: 16px;
|
font-size: 15px;
|
||||||
padding-left: 15px;
|
padding-left: 15px;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
}
|
}
|
||||||
|
BIN
public/favicon.gif
Normal file
After Width: | Height: | Size: 336 B |
@ -150,6 +150,7 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li>Click anywhere in the box to <strong>move</strong></li>
|
<li>Click anywhere in the box to <strong>move</strong></li>
|
||||||
<li>Write <code>/name</code> followed by your name in the text box to <strong>change your name</strong></li>
|
<li>Write <code>/name</code> followed by your name in the text box to <strong>change your name</strong></li>
|
||||||
|
<li>You can change your character with <code>/dino</code> followed by <code>1,2,3,4</code> eg. <code>/dino 2</code> </li>
|
||||||
<li>Use the textbox to <strong>chat</strong> and the emoji button to send <strong>emojis</strong></li>
|
<li>Use the textbox to <strong>chat</strong> and the emoji button to send <strong>emojis</strong></li>
|
||||||
<li>Be nice & Have fun!</li>
|
<li>Be nice & Have fun!</li>
|
||||||
<div class="credits"> Dino sprites by <a href="https://arks.itch.io/dino-characters" target="_blank">@ScissorMarks</a> </div>
|
<div class="credits"> Dino sprites by <a href="https://arks.itch.io/dino-characters" target="_blank">@ScissorMarks</a> </div>
|
||||||
|
@ -81,18 +81,15 @@ socket.on('updatePlayers', (bPlayers) =>{
|
|||||||
skin:bPlayer.skin,
|
skin:bPlayer.skin,
|
||||||
message:'',
|
message:'',
|
||||||
atPosition:true,
|
atPosition:true,
|
||||||
|
isCharacter2D:true,
|
||||||
animationColumn:0,
|
animationColumn:0,
|
||||||
imageSrc:'characterSprites/' + bPlayer.skin + '/Down.png',
|
imageSrc:'characterSprites/' + bPlayer.skin + '/Down.png',
|
||||||
frames: 7,
|
frames: 7,
|
||||||
center:true,
|
center:true,
|
||||||
sprites:{
|
sprites:spriteFunction(bPlayer.skin)
|
||||||
down:'characterSprites/' + bPlayer.skin + '/Down.png',
|
|
||||||
up:'characterSprites/' + bPlayer.skin + '/Up.png',
|
|
||||||
right:'characterSprites/' + bPlayer.skin + '/Right.png',
|
|
||||||
left:'characterSprites/' + bPlayer.skin + '/Left.png'
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
// console.log(fPlayers[id])
|
||||||
fPlayers[socket.id].username = localStorage.getItem('username')
|
fPlayers[socket.id].username = localStorage.getItem('username')
|
||||||
socket.emit('username',fPlayers[socket.id].username);
|
socket.emit('username',fPlayers[socket.id].username);
|
||||||
|
|
||||||
@ -102,7 +99,9 @@ socket.on('updatePlayers', (bPlayers) =>{
|
|||||||
fPlayers[id].clickY = bPlayer.clickY
|
fPlayers[id].clickY = bPlayer.clickY
|
||||||
fPlayers[id].message = bPlayer.message
|
fPlayers[id].message = bPlayer.message
|
||||||
fPlayers[id].username = bPlayer.username
|
fPlayers[id].username = bPlayer.username
|
||||||
fPlayers[id].skin = bPlayer.skin
|
spriteFunctionUpdate(fPlayers[id],bPlayer.skin)
|
||||||
|
// fPlayers[id].sprites = spriteFunction(bPlayer.skin)
|
||||||
|
// console.log(fPlayers[id])
|
||||||
|
|
||||||
//update player position without animation if tab is inactive
|
//update player position without animation if tab is inactive
|
||||||
if (document.hidden) {
|
if (document.hidden) {
|
||||||
@ -207,8 +206,24 @@ document.querySelector('#textInput').addEventListener('submit',(event)=>{
|
|||||||
}else if(inputValue==='/debug'){
|
}else if(inputValue==='/debug'){
|
||||||
if(debugMode) {debugMode=false;}else{debugMode=true;}
|
if(debugMode) {debugMode=false;}else{debugMode=true;}
|
||||||
|
|
||||||
}else if(inputValue==='/red'){
|
}else if(inputValue.includes("/dino ")){
|
||||||
fPlayers[socket.id].skin = "Red";
|
console.log(inputValue.slice(6,7));
|
||||||
|
switch(inputValue.slice(6,7)) {
|
||||||
|
case '1':
|
||||||
|
fPlayers[socket.id].skin = "Green";
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
fPlayers[socket.id].skin = "Red";
|
||||||
|
break;
|
||||||
|
case '3':
|
||||||
|
fPlayers[socket.id].skin = "Orange";
|
||||||
|
break;
|
||||||
|
case '4':
|
||||||
|
fPlayers[socket.id].skin = "Blue";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fPlayers[socket.id].skin = "Green";
|
||||||
|
}
|
||||||
socket.emit('skin',fPlayers[socket.id].skin);
|
socket.emit('skin',fPlayers[socket.id].skin);
|
||||||
}else{
|
}else{
|
||||||
fPlayers[socket.id].message=document.querySelector('#input').value
|
fPlayers[socket.id].message=document.querySelector('#input').value
|
||||||
@ -219,3 +234,21 @@ document.querySelector('#textInput').addEventListener('submit',(event)=>{
|
|||||||
}
|
}
|
||||||
document.querySelector('#textInput').reset();
|
document.querySelector('#textInput').reset();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function spriteFunction(skin) {
|
||||||
|
return {
|
||||||
|
down:'characterSprites/' + skin + '/Down.png',
|
||||||
|
up:'characterSprites/' + skin + '/Up.png',
|
||||||
|
right:'characterSprites/' + skin + '/Right.png',
|
||||||
|
left:'characterSprites/' + skin + '/Left.png'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function spriteFunctionUpdate(obj,skin) {
|
||||||
|
|
||||||
|
obj.Down.src='characterSprites/' + skin + '/Down.png';
|
||||||
|
obj.Up.src='characterSprites/' + skin + '/Up.png';
|
||||||
|
obj.Left.src='characterSprites/' + skin + '/Left.png';
|
||||||
|
obj.Right.src='characterSprites/' + skin + '/Right.png';
|
||||||
|
|
||||||
|
}
|