added final results screen
This commit is contained in:
74
.idea/workspace.xml
generated
74
.idea/workspace.xml
generated
@@ -1,7 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="d9dac41b-fc54-4ab0-93ea-73586523c969" name="Default" comment="" />
|
||||
<list default="true" id="d9dac41b-fc54-4ab0-93ea-73586523c969" name="Default" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/audio.js" beforeDir="false" afterPath="$PROJECT_DIR$/audio.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/background.js" beforeDir="false" afterPath="$PROJECT_DIR$/background.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/game.js" beforeDir="false" afterPath="$PROJECT_DIR$/game.js" afterDir="false" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/.tmp/" />
|
||||
<ignored path="$PROJECT_DIR$/temp/" />
|
||||
<ignored path="$PROJECT_DIR$/tmp/" />
|
||||
@@ -26,8 +30,8 @@
|
||||
<file leaf-file-name="audio.js" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/audio.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1414">
|
||||
<caret line="101" column="52" selection-start-line="101" selection-start-column="52" selection-end-line="101" selection-end-column="52" />
|
||||
<state relative-caret-position="319">
|
||||
<caret line="176" column="11" selection-start-line="176" selection-start-column="11" selection-end-line="176" selection-end-column="11" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@@ -44,8 +48,8 @@
|
||||
<file leaf-file-name="game.js" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/game.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="350">
|
||||
<caret line="164" column="2" lean-forward="true" selection-start-line="164" selection-start-column="2" selection-end-line="164" selection-end-column="107" />
|
||||
<state relative-caret-position="126">
|
||||
<caret line="80" column="45" selection-start-line="80" selection-start-column="45" selection-end-line="80" selection-end-column="45" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@@ -73,8 +77,8 @@
|
||||
<file leaf-file-name="background.js" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/background.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="280">
|
||||
<caret line="128" column="78" selection-start-line="128" selection-start-column="78" selection-end-line="128" selection-end-column="78" />
|
||||
<state relative-caret-position="308">
|
||||
<caret line="152" column="61" selection-start-line="152" selection-start-column="61" selection-end-line="152" selection-end-column="61" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@@ -90,9 +94,6 @@
|
||||
</component>
|
||||
<component name="FindInProjectRecents">
|
||||
<findStrings>
|
||||
<find>scree</find>
|
||||
<find>console.log</find>
|
||||
<find>gameloo</find>
|
||||
<find>drawcoun</find>
|
||||
<find>screensizead</find>
|
||||
<find>drawrace</find>
|
||||
@@ -111,12 +112,18 @@
|
||||
<find>countdown</find>
|
||||
<find>horse_image_ar</find>
|
||||
<find>drawracebackground</find>
|
||||
<find>ctx.</find>
|
||||
<find>drawcountdown</find>
|
||||
<find>inithorses</find>
|
||||
<find>horse_Array</find>
|
||||
<find>draw horses</find>
|
||||
<find>line</find>
|
||||
<find>finished</find>
|
||||
<find>drawcountdown</find>
|
||||
<find>coun</find>
|
||||
<find>horseheigh</find>
|
||||
<find>ctx.</find>
|
||||
<find>finalplaces</find>
|
||||
<find>rect</find>
|
||||
<find>canvas</find>
|
||||
</findStrings>
|
||||
<replaceStrings>
|
||||
<replace>cyclesRemaining</replace>
|
||||
@@ -149,7 +156,7 @@
|
||||
</component>
|
||||
<component name="ProjectFrameBounds" extendedState="6">
|
||||
<option name="x" value="-1367" />
|
||||
<option name="y" value="-785" />
|
||||
<option name="y" value="-17" />
|
||||
<option name="width" value="1368" />
|
||||
<option name="height" value="786" />
|
||||
</component>
|
||||
@@ -166,6 +173,24 @@
|
||||
<item name="HorseRaceGame" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="HorseRaceGame" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="HorseRaceGame" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="HorseRaceGame" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="resources" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="HorseRaceGame" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="HorseRaceGame" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="resources" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="audio" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="HorseRaceGame" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="HorseRaceGame" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="resources" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="audio" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="fanfare" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
@@ -215,24 +240,25 @@
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1562211281380</updated>
|
||||
<workItem from="1562211282530" duration="37792000" />
|
||||
<workItem from="1563080090211" duration="13172000" />
|
||||
<workItem from="1563080090211" duration="15794000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="50964000" />
|
||||
<option name="totallyTimeSpent" value="53586000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="-1" y="-785" width="1368" height="786" extended-state="6" />
|
||||
<frame x="-1367" y="-17" width="1368" height="786" extended-state="6" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.2108389" />
|
||||
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.2108389" />
|
||||
<window_info anchor="bottom" id="TODO" order="6" />
|
||||
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
|
||||
<window_info anchor="bottom" id="Event Log" order="7" side_tool="true" />
|
||||
<window_info anchor="bottom" id="Version Control" order="7" />
|
||||
<window_info anchor="bottom" id="Run" order="2" />
|
||||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
||||
<window_info active="true" anchor="bottom" id="Terminal" order="7" visible="true" weight="0.32882884" />
|
||||
<window_info anchor="bottom" id="Terminal" order="7" visible="true" weight="0.32882884" />
|
||||
<window_info id="Favorites" order="2" side_tool="true" />
|
||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
||||
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
||||
@@ -324,22 +350,22 @@
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/audio.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1414">
|
||||
<caret line="101" column="52" selection-start-line="101" selection-start-column="52" selection-end-line="101" selection-end-column="52" />
|
||||
<state relative-caret-position="319">
|
||||
<caret line="176" column="11" selection-start-line="176" selection-start-column="11" selection-end-line="176" selection-end-column="11" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/background.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="280">
|
||||
<caret line="128" column="78" selection-start-line="128" selection-start-column="78" selection-end-line="128" selection-end-column="78" />
|
||||
<state relative-caret-position="308">
|
||||
<caret line="152" column="61" selection-start-line="152" selection-start-column="61" selection-end-line="152" selection-end-column="61" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/game.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="350">
|
||||
<caret line="164" column="2" lean-forward="true" selection-start-line="164" selection-start-column="2" selection-end-line="164" selection-end-column="107" />
|
||||
<state relative-caret-position="126">
|
||||
<caret line="80" column="45" selection-start-line="80" selection-start-column="45" selection-end-line="80" selection-end-column="45" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
||||
26
audio.js
26
audio.js
@@ -97,6 +97,27 @@ const gallops = [
|
||||
|
||||
];
|
||||
|
||||
const fanfare = [
|
||||
new Howl({
|
||||
src:['resources/audio/fanfare/100422__robinhood76__01851-cartoon-fanfare.wav'],
|
||||
}),
|
||||
new Howl({
|
||||
src:['resources/audio/fanfare/198874__bone666138__fanfare.wav'],
|
||||
}),
|
||||
new Howl({
|
||||
src:['resources/audio/fanfare/321937__pel2na__two-kazoo-fanfare.wav'],
|
||||
}),
|
||||
new Howl({
|
||||
src:['resources/audio/fanfare/413204__joepayne__clean-trumpet-fanfare-with-wobble.mp3'],
|
||||
}),
|
||||
new Howl({
|
||||
src:['resources/audio/fanfare/418526__audeption__fasching-fanfare-karnevals-tusch-tataa-long.wav'],
|
||||
}),
|
||||
new Howl({
|
||||
src:['resources/audio/fanfare/470083__sheyvan__music-orchestral-victory-fanfare.wav'],
|
||||
}),
|
||||
];
|
||||
|
||||
|
||||
function playRandomNeigh(){
|
||||
const index = Math.floor(Math.random() * effects.length);
|
||||
@@ -150,3 +171,8 @@ function stopGallop(){
|
||||
gallops[1].stop();
|
||||
|
||||
}
|
||||
|
||||
function playFanfare(){
|
||||
const index = Math.floor(Math.random() * fanfare.length);
|
||||
fanfare[index].play();
|
||||
}
|
||||
@@ -128,3 +128,29 @@ function drawHorseNamesinLane(ctx,horse, lane, horseSize, height) {
|
||||
|
||||
ctx.fillText(horse.name, horseSize, height - (lane * (horseSize / 2 )) -20);
|
||||
}
|
||||
|
||||
function drawResults(ctx, width, height, horseSize, finalPlaces){
|
||||
drawRaceBackground(ctx,width,height,horseSize, 0, false);
|
||||
// draw rectangle
|
||||
ctx.fillStyle = '#dddddd';
|
||||
ctx.fillRect(horseSize*2, height - (.5 * horseSize) , (horseSize *4), - (horseSize * 3));
|
||||
|
||||
ctx.fillStyle = '#9999FF';
|
||||
ctx.fillRect(horseSize*2 + 3, height - (.5 * horseSize) -3 , (horseSize *4) -6, - (horseSize * 3) + 6 );
|
||||
|
||||
|
||||
const first = "1ST - " + finalPlaces[0].name;
|
||||
const second = "2ND - " + finalPlaces[1].name;
|
||||
const third = "3RD - " + finalPlaces[2].name;
|
||||
const fourth = "4TH - " + finalPlaces[3].name;
|
||||
|
||||
ctx.fillStyle = "#000000";
|
||||
ctx.font = "40px Arial";
|
||||
|
||||
ctx.fillText("Final Results", horseSize* 3, height - (horseSize * 3));
|
||||
ctx.fillText(first, horseSize* 2.5, height - (horseSize * 2.5));
|
||||
ctx.fillText(second, horseSize* 2.5, height - (horseSize * 2));
|
||||
ctx.fillText(third, horseSize* 2.5, height -(horseSize * 1.5));
|
||||
ctx.fillText(fourth,horseSize* 2.5, height - (horseSize));
|
||||
|
||||
}
|
||||
5
game.js
5
game.js
@@ -76,6 +76,10 @@ function gameLoop(){
|
||||
screenReset();
|
||||
runRace(CTX,BG_CTX);
|
||||
break;
|
||||
|
||||
case "finished":
|
||||
CTX.clearRect(0, 0, WIDTH, HEIGHT);
|
||||
drawResults(BG_CTX, WIDTH, HEIGHT, horseHeight, finalPlaces);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -192,6 +196,7 @@ function runRace(ctx,bg_ctx){
|
||||
if (finalPlaces.length === 4){
|
||||
gameState = "finished";
|
||||
stopGallop();
|
||||
playFanfare();
|
||||
}
|
||||
finishLineScan -= finishLineSpeed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user