Skip to content

Commit

Permalink
NSP: more districts for beginner
Browse files Browse the repository at this point in the history
  • Loading branch information
DrDr3ck committed Aug 4, 2024
1 parent 91bbd4c commit 83e0c86
Show file tree
Hide file tree
Showing 3 changed files with 200 additions and 24 deletions.
28 changes: 17 additions & 11 deletions NextStation-Paris/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ class Overhead {
}
}

const CARDS = {
UNDERGROUND: "blue",
SURFACE: "yellow",
SWITCH: "switch",
};

class Card {
constructor(cardIndex, color, symbol) {
this.index = cardIndex;
Expand All @@ -255,17 +261,17 @@ class Card {

function getCards() {
const cards = [];
cards.push(new Card(1, "blue", SHAPES.CIRCLE));
cards.push(new Card(2, "blue", SHAPES.TRIANGLE));
cards.push(new Card(3, "blue", SHAPES.PENTAGONE));
cards.push(new Card(4, "blue", SHAPES.SQUARE));
cards.push(new Card(5, "blue", SHAPES.JOKER));
cards.push(new Card(6, "switch", SHAPES.JOKER)); // SWITCH
cards.push(new Card(7, "yellow", SHAPES.PENTAGONE));
cards.push(new Card(8, "yellow", SHAPES.CIRCLE));
cards.push(new Card(9, "yellow", SHAPES.TRIANGLE));
cards.push(new Card(10, "yellow", SHAPES.SQUARE));
cards.push(new Card(11, "yellow", SHAPES.JOKER));
cards.push(new Card(1, CARDS.UNDERGROUND, SHAPES.CIRCLE));
cards.push(new Card(2, CARDS.UNDERGROUND, SHAPES.TRIANGLE));
cards.push(new Card(3, CARDS.UNDERGROUND, SHAPES.PENTAGONE));
cards.push(new Card(4, CARDS.UNDERGROUND, SHAPES.SQUARE));
cards.push(new Card(5, CARDS.UNDERGROUND, SHAPES.JOKER));
cards.push(new Card(6, CARDS.SWITCH, SHAPES.JOKER)); // SWITCH
cards.push(new Card(7, CARDS.SURFACE, SHAPES.PENTAGONE));
cards.push(new Card(8, CARDS.SURFACE, SHAPES.CIRCLE));
cards.push(new Card(9, CARDS.SURFACE, SHAPES.TRIANGLE));
cards.push(new Card(10, CARDS.SURFACE, SHAPES.SQUARE));
cards.push(new Card(11, CARDS.SURFACE, SHAPES.JOKER));
return cards;
}

Expand Down
196 changes: 183 additions & 13 deletions NextStation-Paris/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,71 @@ const scoreUI = {
bottomRight: { x: 903, y: 665 },
},
},
{
districts: {
topLeft: { x: 920, y: 513 },
bottomRight: { x: 960, y: 550 },
},
stations: {
topLeft: { x: 920, y: 570 },
bottomRight: { x: 960, y: 607 },
},
monuments: {
topLeft: { x: 920, y: 625 },
bottomRight: { x: 960, y: 665 },
},
},
{
districts: {
topLeft: { x: 980, y: 513 },
bottomRight: { x: 1017, y: 550 },
},
stations: {
topLeft: { x: 980, y: 570 },
bottomRight: { x: 1017, y: 607 },
},
monuments: {
topLeft: { x: 980, y: 625 },
bottomRight: { x: 1017, y: 665 },
},
},
{
districts: {
topLeft: { x: 980, y: 513 },
bottomRight: { x: 1017, y: 550 },
},
stations: {
topLeft: { x: 980, y: 570 },
bottomRight: { x: 1017, y: 607 },
},
monuments: {
topLeft: { x: 980, y: 625 },
bottomRight: { x: 1017, y: 665 },
},
},
{
districts: {
topLeft: { x: 1036, y: 513 },
bottomRight: { x: 1076, y: 550 },
},
stations: {
topLeft: { x: 1036, y: 570 },
bottomRight: { x: 1076, y: 607 },
},
monuments: {
topLeft: { x: 1036, y: 625 },
bottomRight: { x: 1076, y: 665 },
},
},
],
links: {
two: {},
three: {},
four: {},
two: { topLeft: { x: 1159, y: 513 }, bottomRight: { x: 1198, y: 550 } },
three: { topLeft: { x: 1159, y: 570 }, bottomRight: { x: 1198, y: 607 } },
four: { topLeft: { x: 1159, y: 625 }, bottomRight: { x: 1198, y: 665 } },
},
overheads: {
one: {},
two: {},
one: { topLeft: { x: 1035, y: 739 }, bottomRight: { x: 1074, y: 772 } },
two: { topLeft: { x: 1158, y: 739 }, bottomRight: { x: 1198, y: 772 } },
},
};

Expand Down Expand Up @@ -136,6 +192,7 @@ function setup() {
spritesheet.addSpriteSheet("paris", "./paris.png", 770, 765);
spritesheet.addSpriteSheet("score", "./score.png", 615, 315);
spritesheet.addSpriteSheet("cards", "./cards.png", 325, 210);
spritesheet.addSpriteSheet("skip", "./skip.png", 100, 100);
spritesheet.addSpriteSheet("switch", "./switch.png", 131, 131);
spritesheet.addSpriteSheet("crayons", "./crayons.png", 93, 93);

Expand Down Expand Up @@ -184,6 +241,7 @@ function startLine() {
}
}

// display district for beginner
function displayDistrict(district) {
noFill();
stroke(0);
Expand All @@ -196,6 +254,30 @@ function displayDistrict(district) {
vertex(20, 74);
endShape(CLOSE);
}
if (district === 2) {
beginShape();
vertex(720, 26);
vertex(777, 26);
vertex(777, 74);
vertex(720, 74);
endShape(CLOSE);
}
if (district === 3) {
beginShape();
vertex(20, 713);
vertex(84, 713);
vertex(84, 770);
vertex(20, 770);
endShape(CLOSE);
}
if (district === 4) {
beginShape();
vertex(720, 428);
vertex(777, 428);
vertex(777, 769);
vertex(720, 769);
endShape(CLOSE);
}
if (district === 5) {
beginShape();
vertex(20, 92);
Expand All @@ -206,6 +288,16 @@ function displayDistrict(district) {
vertex(20, 153);
endShape(CLOSE);
}
if (district === 6) {
beginShape();
vertex(415, 23);
vertex(700, 23);
vertex(700, 92);
vertex(770, 92);
vertex(770, 153);
vertex(415, 153);
endShape(CLOSE);
}
if (district === 7) {
beginShape();
vertex(20, 175);
Expand All @@ -216,6 +308,16 @@ function displayDistrict(district) {
vertex(20, 383);
endShape(CLOSE);
}
if (district === 8) {
beginShape();
vertex(415, 175);
vertex(770, 175);
vertex(770, 383);
vertex(493, 383);
vertex(493, 308);
vertex(415, 308);
endShape(CLOSE);
}
if (district === 9) {
beginShape();
vertex(20, 408);
Expand All @@ -236,6 +338,26 @@ function displayDistrict(district) {
vertex(415, 615);
endShape(CLOSE);
}
if (district === 11) {
beginShape();
vertex(20, 638);
vertex(390, 638);
vertex(390, 770);
vertex(100, 770);
vertex(100, 693);
vertex(20, 693);
endShape(CLOSE);
}
if (district === 12) {
beginShape();
vertex(410, 638);
vertex(773, 638);
vertex(773, 693);
vertex(695, 693);
vertex(695, 770);
vertex(410, 770);
endShape(CLOSE);
}
if (district === 13) {
beginShape();
vertex(337, 331);
Expand All @@ -246,6 +368,16 @@ function displayDistrict(district) {
}
}

function displayOverHeads(overheadType) {
const overheads = getOverHeads(overheadType);
overheads.forEach((station) => displayStation(station, "black"));
}

function displayLinks(linkType) {
const links = getLinks(linkType);
links.forEach((station) => displayStation(station, "black"));
}

function displayMonuments(monumentColor) {
if (!monumentColor) {
return;
Expand Down Expand Up @@ -381,6 +513,7 @@ let stations = [];
let sections = [];

let cards = [];
let countUnderground = 0;

function displayLines() {
allStationLines.forEach((cur, index) =>
Expand All @@ -406,14 +539,14 @@ function displayLine(color, line, lastLine) {
sections.forEach((section) => displaySection(section));
}

function getOverHead(num) {
function getOverHeads(num) {
// TODO: score for overhead
return 0;
return [];
}

function getLinks(num) {
// TODO: score for links
return 0;
return [];
}

function getCrossedDistricts(stationLine) {
Expand Down Expand Up @@ -479,17 +612,25 @@ function drawScore() {
// total station lines
text(total, 1115, 700);
// TODO: overhead
const overhead2 = getOverHead(1);
const overhead6 = getOverHead(2);
const overhead2 = getOverHeads(1).length;
const overhead6 = getOverHeads(2).length;
text(overhead2, 1056, 755);
text(overhead6, 1178, 755);

text(overhead2 * 2 + overhead6 * 6, 1178, 700);
total += overhead2 * 2 + overhead6 * 6;
// TODO: correspondance
const link2 = getLinks(2);
const link5 = getLinks(3);
const link9 = getLinks(4);
const link2 = getLinks(2).length;
const link5 = getLinks(3).length;
const link9 = getLinks(4).length;

text(link2, 1179, 536);
text(link5, 1179, 590);
text(link9, 1179, 644);

text(link2 * 2, 1243, 536);
text(link5 * 5, 1243, 590);
text(link9 * 9, 1243, 644);

text(link2 * 2 + link5 * 5 + link9 * 9, 1242, 700);
total += link2 * 2 + link5 * 5 + link9 * 9;
Expand Down Expand Up @@ -529,18 +670,30 @@ function drawGame() {

displayPencil();

spritesheet.drawSprite("skip", 0, 1360, 120);

displayLines();

displayStation(over.station, pencils[round]);

// for beginner
displayDistricts(over.districts);
displayStations(over.stations);
displayMonuments(over.monuments);
displayLinks(over.links);
displayOverHeads(over.overheads);
// end beginner

if (clickedStation) {
drawLine(clickedStation);
}

const rgb = getRGBColor();
noFill();
strokeWeight(10);
stroke(rgb[0], rgb[1], rgb[2]);
rect(0, 0, width, height);

/* debug
stroke(80);
strokeWeight(2);
Expand Down Expand Up @@ -721,6 +874,11 @@ function mouseClicked() {
clickedStation = null;
}
}

// skip turn
if (distance(mouseX, mouseY, 1410, 169) < 40) {
nextCard();
}
return false;
}

Expand Down Expand Up @@ -758,6 +916,18 @@ function mouseMoved() {
over.monuments = pencils[index];
}
});
if (mouseInSquare(scoreUI.links.two)) {
over.links = 2;
} else if (mouseInSquare(scoreUI.links.three)) {
over.links = 3;
} else if (mouseInSquare(scoreUI.links.four)) {
over.links = 4;
}
if (mouseInSquare(scoreUI.overheads.one)) {
over.overheads = 1;
} else if (mouseInSquare(scoreUI.links.two)) {
over.overheads = 2;
}
}

function keyPressed() {
Expand Down
Binary file added NextStation-Paris/skip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 83e0c86

Please sign in to comment.