Skip to content

Commit

Permalink
Restructure clothing items; Add Face items
Browse files Browse the repository at this point in the history
  • Loading branch information
alesan99 committed Nov 19, 2023
1 parent 2f9dc49 commit 7c6863f
Show file tree
Hide file tree
Showing 29 changed files with 231 additions and 189 deletions.
5 changes: 3 additions & 2 deletions website/assets/areas/alleyway.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
"profile": {
"name": "???",
"color": [40, 80, 50],
"hat": "hoodie",
"accessory": false
"head": "hoodie",
"face": false,
"body": false
},
"x": 810,
"y": 300,
Expand Down
10 changes: 6 additions & 4 deletions website/assets/areas/arcade.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
"profile": {
"name": "Bud",
"color": [200, 210, 255],
"hat": "visors",
"accessory": "alesanaccessories"
"head": "visors",
"face": false,
"body": "alesanaccessories"
},
"x": 406,
"y": 290,
Expand All @@ -54,8 +55,9 @@
"profile": {
"name": "Pro Gamer",
"color": [40, 40, 40],
"hat": false,
"accessory": false
"head": false,
"face": false,
"body": false
},
"x": 820,
"y": 500,
Expand Down
19 changes: 12 additions & 7 deletions website/assets/areas/chictoriassecret.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
"profile": {
"name": "Beefcake",
"color": [255, 240, 255],
"hat": false,
"accessory": "beefcakeaccessories"
"head": false,
"face": false,
"body": "beefcakeaccessories"
},
"x": 850,
"y": 480,
Expand All @@ -52,11 +53,15 @@
],
"shop": {
"name": "Chictoria's Secret",
"items": [
["accessory", "scarf"],
["hat", "tophat"],
["accessory", "chains"]
]
"items": {
"head": {
"tophat": true
},
"body": {
"scarf": true,
"chains": true
}
}
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions website/assets/areas/seeddispensary.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
"profile": {
"name": "Seedtender",
"color": [132, 211, 74],
"hat": "snapback",
"accessory": "silverchains"
"head": "snapback",
"face": false,
"body": "silverchains"
},
"x": 830,
"y": 360,
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
119 changes: 53 additions & 66 deletions website/game/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,17 @@ function loadGameAssets() {
IMG.menu = new RenderImage("assets/gui/menu.png")

// Chicken Customization
// TODO: Clean up this horrible code

// DIRECTORYTREE = fetch('/getDirectoryTree')
// .then(response => {
// if (!response.ok) { throw new Error('Failed to fetch directory tree'); };
// return response.json()
// })
// .then(data => {
// DIRECTORYTREE = data
// })
// .catch(error => { console.error(error) });
// console.log(DIRECTORYTREE)

HATOFFSET = [ // Center of chicken head where hat should be placed
HEADOFFSET = [ // Center of chicken head where hat should be placed
[[64,1],[64,1],[66,2] ,[66,9],[64,2],[64,2],[4,62],[64,1]],
[[89,3],[89,3],[86,10],[66,9],[64,2],[64,2],[4,62],[64,1]],
[[63,2],[63,2],[66,2] ,[66,9],[64,2],[64,2],[4,62],[64,1]]
]
FACEOFFSET = [ // Center of chicken face where glasses should be placed
[[64,1],[64,1],[66,2] ,[66,9],[64,2],[64,2],[4,62],[64,1]],
[[89,3],[89,3],[86,10],[66,9],[64,2],[64,2],[4,62],[64,1]],
[[63,2],[63,2],[66,2] ,[66,9],[64,2],[64,2],[4,62],[64,1]]
]
ACCESSORYOFFSET = [ // Center of chicken chin where accessory should be placed
BODYOFFSET = [ // Center of chicken chin where accessory should be placed
[[64,55],[64,55],[66,56],[66,63],[64,55],[64,55],[59,62],[64,55]],
[[89,49],[89,49],[86,52],[66,63],[64,55],[64,55],[59,62],[64,55]],
[[63,56],[63,56],[68,57],[66,63],[64,55],[64,55],[59,62],[64,55]]
Expand All @@ -72,62 +64,45 @@ function loadGameAssets() {
]

// Load all items
ITEMLIST = {
hats: {},
accessories: {},
ITEMS = {
// Categories
head: {},
face: {},
body: {},
furniture: {},
items: {}
item: {}
}
// List of all hats to load
HAT = ITEMLIST.hats
HAT["tophat"] = {}
HAT["visors"] = {}
HAT["snapback"] = {}
HAT["hoodie"] = {}

for (const [name, value] of Object.entries(HAT)) {
// Load image, create sprite frames when image is loaded, and load hat centers from JSON
let async = function() {
HAT[name].sprite = new Sprite(HAT[name].image, 1, 3, HAT[name].image.w,(HAT[name].image.h-2)/3, 0,0, 1,1)
}
HAT[name].image = new RenderImage(`assets/hats/${name}.png`, async)
HAT[name].center = [[0.5, 0.7],[0.5, 0.7],[0.5, 0.7]]
HAT[name].cost = 0
HAT[name].name = ""
loadJSON(`assets/hats/${name}.json`, (data) => {
HAT[name].name = data.name
HAT[name].center = data.center
HAT[name].cost = data.cost
})
}
// List of all accessories to load
ACCESSORY = ITEMLIST.accessories
ACCESSORY["scarf"] = {}
ACCESSORY["chains"] = {}
ACCESSORY["silverchains"] = {}
ACCESSORY["beefcakeaccessories"] = {}
ACCESSORY["alesanaccessories"] = {}

for (const [name, value] of Object.entries(ACCESSORY)) {
// Load image, create sprite frames when image is loaded, and load accessory centers from JSON
let async = function() {
ACCESSORY[name].sprite = new Sprite(ACCESSORY[name].image, 1, 3, ACCESSORY[name].image.w, (ACCESSORY[name].image.h-2)/3, 0,0, 1,1)
// List of all items to load
ITEMS.head["tophat"] = {}
ITEMS.head["snapback"] = {}
ITEMS.head["hoodie"] = {}

ITEMS.face["visors"] = {}

ITEMS.body["scarf"] = {}
ITEMS.body["chains"] = {}
ITEMS.body["silverchains"] = {}
ITEMS.body["beefcakeaccessories"] = {}
ITEMS.body["alesanaccessories"] = {}

for (const [category, list] of Object.entries(ITEMS)) {
for (const [itemId, item] of Object.entries(list)) {
// Load image, create sprite frames when image is loaded, and load hat centers from JSON
let async = function() {
item.sprite = new Sprite(item.image, 1, 3, item.image.w,(item.image.h-2)/3, 0,0, 1,1)
}
item.image = new RenderImage(`assets/items/${category}/${itemId}.png`, async)
item.center = [[0.5, 0.7],[0.5, 0.7],[0.5, 0.7]]
item.cost = 0
item.name = ""
loadJSON(`assets/items/${category}/${itemId}.json`, (data) => {
item.name = data.name
item.center = data.center
item.cost = data.cost
})
}
ACCESSORY[name].image = new RenderImage(`assets/accessories/${name}.png`, async)
ACCESSORY[name].center = [[0.5, 0],[0.5, 0],[0.5, 0]]
ACCESSORY[name].cost = 0
ACCESSORY[name].name = ""
loadJSON(`assets/accessories/${name}.json`, (data) => {
ACCESSORY[name].name = data.name
ACCESSORY[name].center = data.center
ACCESSORY[name].cost = data.cost
})
}

// List of all items to load
FURNITURE = ITEMLIST.furniture
ITEM = ITEMLIST.items

FONT.pixel = new RenderFont("Pixel", 16)
FONT.big = new RenderFont("Arial", 40)
FONT.hud = new RenderFont("Arial", 28)
Expand All @@ -154,3 +129,15 @@ function loadJSON(filePath, callBack) {
})
}

// TODO: Clean up this horrible code

// DIRECTORYTREE = fetch('/getDirectoryTree')
// .then(response => {
// if (!response.ok) { throw new Error('Failed to fetch directory tree'); };
// return response.json()
// })
// .then(data => {
// DIRECTORYTREE = data
// })
// .catch(error => { console.error(error) });
// console.log(DIRECTORYTREE)
12 changes: 8 additions & 4 deletions website/game/menu/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ MENUS["chatMenu"] = new class extends Menu {
PROFILE.color = [Number(arg), Number(arg2), Number(arg3)]
PLAYER.updateProfile(PROFILE, "sendToServer")
break
case "/hat":
PROFILE.hat = arg
case "/head":
PROFILE.head = arg
PLAYER.updateProfile(PROFILE, "sendToServer")
break
case "/accessory":
PROFILE.accessory = arg
case "/face":
PROFILE.face = arg
PLAYER.updateProfile(PROFILE, "sendToServer")
break
case "/body":
PROFILE.body = arg
PLAYER.updateProfile(PROFILE, "sendToServer")
break
case "/scale": // Chicken size
Expand Down
75 changes: 58 additions & 17 deletions website/game/menu/customization.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,65 @@ MENUS["customization"] = new class extends Menu {
Math.floor(100 + Math.random()*155)];
PLAYER.updateProfile(PROFILE, "sendToServer");
}, null, 665,202, 100,32)
// Hat
this.buttons["hatLeft"] = new Button("<", ()=>{
PROFILE.hat = SAVEDATA.hats[Math.floor(Math.random()*SAVEDATA.hats.length)];
// Head Item
this.buttons["headLeft"] = new Button("<", ()=>{
let keys = Object.keys(SAVEDATA.items.head);
if (keys.length === 0) {
PROFILE.head = false
} else {
PROFILE.head = keys[Math.floor(Math.random() * keys.length)];
}
PLAYER.updateProfile(PROFILE, "sendToServer");
}, null, 605,242, 32,32)
this.buttons["hatRight"] = new Button(">", ()=>{
PROFILE.hat = SAVEDATA.hats[Math.floor(Math.random()*SAVEDATA.hats.length)];
this.buttons["headRight"] = new Button(">", ()=>{
let keys = Object.keys(SAVEDATA.items.head);
if (keys.length === 0) {
PROFILE.head = false
} else {
PROFILE.head = keys[Math.floor(Math.random() * keys.length)];
}
PLAYER.updateProfile(PROFILE, "sendToServer");
}, null, 733,242, 32,32)
// Accessory
this.buttons["accessoryLeft"] = new Button("<", ()=>{
PROFILE.accessory = SAVEDATA.accessories[Math.floor(Math.random()*SAVEDATA.accessories.length)];
// Face Item
this.buttons["faceLeft"] = new Button("<", ()=>{
let keys = Object.keys(SAVEDATA.items.face);
if (keys.length == 0) {
PROFILE.face = false
} else {
PROFILE.face = keys[Math.floor(Math.random() * keys.length)];
}
PLAYER.updateProfile(PROFILE, "sendToServer");
}, null, 605,282, 32,32)
this.buttons["accessoryRight"] = new Button(">", ()=>{
PROFILE.accessory = SAVEDATA.accessories[Math.floor(Math.random()*SAVEDATA.accessories.length)];
this.buttons["faceRight"] = new Button(">", ()=>{
let keys = Object.keys(SAVEDATA.items.face);
if (keys.length == 0) {
PROFILE.face = false
} else {
PROFILE.face = keys[Math.floor(Math.random() * keys.length)];
}
PLAYER.updateProfile(PROFILE, "sendToServer");
}, null, 733,282, 32,32)
// Body Item
this.buttons["bodyLeft"] = new Button("<", ()=>{
let keys = Object.keys(SAVEDATA.items.body);
if (keys.length == 0) {
PROFILE.body = false
} else {
PROFILE.body = keys[Math.floor(Math.random() * keys.length)];
}
PLAYER.updateProfile(PROFILE, "sendToServer");
}, null, 605,322, 32,32)
this.buttons["bodyRight"] = new Button(">", ()=>{
let keys = Object.keys(SAVEDATA.items.body);
if (keys.length == 0) {
PROFILE.body = false
} else {
PROFILE.body = keys[Math.floor(Math.random() * keys.length)];
}
PLAYER.updateProfile(PROFILE, "sendToServer");
}, null, 733,282, 32,32)
}, null, 733,322, 32,32)
// Pet
this.buttons["pet"] = new Button("None", ()=>{}, null, 665,322, 100,32)
this.buttons["pet"] = new Button("None", ()=>{}, null, 665,362, 100,32)
}

keyPress(key) {
Expand Down Expand Up @@ -88,11 +127,13 @@ MENUS["customization"] = new class extends Menu {

DRAW.text("Display Name", 460, 184, "left")
DRAW.text("Color", 460, 224, "left")
DRAW.text("Hat", 460, 264, "left")
DRAW.text(PROFILE.hat, 686, 264, "center")
DRAW.text("Accessory", 460, 304, "left")
DRAW.text(PROFILE.accessory, 686, 304, "center")
DRAW.text("Pet", 460, 344, "left")
DRAW.text("Head Item", 460, 264, "left")
DRAW.text(PROFILE.head, 686, 264, "center")
DRAW.text("Face Item", 460, 304, "left")
DRAW.text(PROFILE.face, 686, 304, "center")
DRAW.text("Body Item", 460, 344, "left")
DRAW.text(PROFILE.body, 686, 344, "center")
DRAW.text("Pet", 460, 384, "left")

PLAYER.draw(342,340)

Expand Down
Loading

0 comments on commit 7c6863f

Please sign in to comment.