cleaned up game.js a bit, still lots of work to do

This commit is contained in:
2019-07-04 03:35:20 -05:00
parent 6d097c54e1
commit f066280c2f
2 changed files with 75 additions and 28 deletions

91
.idea/workspace.xml generated
View File

@@ -1,7 +1,28 @@
<?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 afterPath="$PROJECT_DIR$/.idea/HorseRaceGame.iml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/background.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/game.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/index.html" afterDir="false" />
<change afterPath="$PROJECT_DIR$/main.css" afterDir="false" />
<change afterPath="$PROJECT_DIR$/resources/horse_images/final/BlackJack_10.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/resources/horse_images/final/CrotchRocket_93_raw.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/resources/horse_images/final/DEMON_HORZE_666.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/resources/horse_images/final/stonewall_000.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/resources/horse_images/gimp_file/BlackJack_10.xcf" afterDir="false" />
<change afterPath="$PROJECT_DIR$/resources/horse_images/gimp_file/CrotchRocket_93_raw.xcf" afterDir="false" />
<change afterPath="$PROJECT_DIR$/resources/horse_images/gimp_file/DEMON_HORZE_666.xcf" afterDir="false" />
<change afterPath="$PROJECT_DIR$/resources/horse_images/gimp_file/stonewall_000_raw.xcf" afterDir="false" />
<change afterPath="$PROJECT_DIR$/resources/horse_images/uncropped/BlackJack_10.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/resources/horse_images/uncropped/CrotchRocket_93_raw.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/resources/horse_images/uncropped/DEMON_HORZE_666.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/resources/horse_images/uncropped/stonewall_000_raw.jpg" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/.tmp/" />
<ignored path="$PROJECT_DIR$/temp/" />
<ignored path="$PROJECT_DIR$/tmp/" />
@@ -32,15 +53,35 @@
</provider>
</entry>
</file>
<file leaf-file-name="game.js" pinned="false" current-in-tab="true">
<file leaf-file-name="game.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/game.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="210">
<caret line="18" column="52" selection-start-line="18" selection-start-column="52" selection-end-line="18" selection-end-column="52" />
<state relative-caret-position="-1218">
<caret line="36" column="70" selection-start-line="36" selection-start-column="70" selection-end-line="36" selection-end-column="70" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="CrotchRocket_93_raw.png" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/resources/horse_images/final/CrotchRocket_93_raw.png">
<provider selected="true" editor-type-id="images" />
</entry>
</file>
<file leaf-file-name="DEMON_HORZE_666.png" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/resources/horse_images/final/DEMON_HORZE_666.png">
<provider selected="true" editor-type-id="images" />
</entry>
</file>
<file leaf-file-name="stonewall_000.png" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/resources/horse_images/final/stonewall_000.png">
<provider selected="true" editor-type-id="images" />
</entry>
</file>
<file leaf-file-name="BlackJack_10.png" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/resources/horse_images/final/BlackJack_10.png">
<provider selected="true" editor-type-id="images" />
</entry>
</file>
<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">
@@ -65,6 +106,9 @@
<find>console.log</find>
</findStrings>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
@@ -86,10 +130,12 @@
<packageJsonPaths />
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="y" value="-3" />
<option name="x" value="-1366" />
<option name="y" value="-771" />
<option name="width" value="1366" />
<option name="height" value="771" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
@@ -168,25 +214,24 @@
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1562211281380</updated>
<workItem from="1562211282530" duration="16638000" />
<workItem from="1562211282530" duration="17564000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="16638000" />
<option name="totallyTimeSpent" value="17564000" />
</component>
<component name="ToolWindowManager">
<frame x="-1366" y="-771" width="1366" height="771" extended-state="6" />
<editor active="true" />
<frame x="0" y="-771" width="1366" height="771" extended-state="6" />
<layout>
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.2108389" />
<window_info 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" show_stripe_button="false" />
<window_info anchor="bottom" id="Event Log" side_tool="true" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="bottom" id="Version Control" show_stripe_button="false" />
<window_info anchor="bottom" id="Version Control" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Terminal" visible="true" weight="0.32882884" />
<window_info active="true" anchor="bottom" id="Terminal" visible="true" weight="0.32882884" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info id="Favorites" side_tool="true" />
<window_info anchor="bottom" id="Find" order="1" />
@@ -231,18 +276,24 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/resources/horse_images/final/CrotchRocket_93_raw.png">
<provider selected="true" editor-type-id="images" />
<entry file="file://$PROJECT_DIR$/game.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1218">
<caret line="36" column="70" selection-start-line="36" selection-start-column="70" selection-end-line="36" selection-end-column="70" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/resources/horse_images/final/BlackJack_10.png">
<provider selected="true" editor-type-id="images" />
</entry>
<entry file="file://$PROJECT_DIR$/game.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="210">
<caret line="18" column="52" selection-start-line="18" selection-start-column="52" selection-end-line="18" selection-end-column="52" />
</state>
</provider>
<entry file="file://$PROJECT_DIR$/resources/horse_images/final/DEMON_HORZE_666.png">
<provider selected="true" editor-type-id="images" />
</entry>
<entry file="file://$PROJECT_DIR$/resources/horse_images/final/CrotchRocket_93_raw.png">
<provider selected="true" editor-type-id="images" />
</entry>
<entry file="file://$PROJECT_DIR$/resources/horse_images/final/stonewall_000.png">
<provider selected="true" editor-type-id="images" />
</entry>
</component>
</project>

12
game.js
View File

@@ -30,17 +30,11 @@ const CTX = GAME_CANVAS.getContext("2d");
let WIDTH = GAME_CANVAS.width;
let HEIGHT = GAME_CANVAS.height;
let horseWidth = WIDTH / 8;
let horseHeight = WIDTH / 8;
// state tracking
const gameState = "running"; // this should probably be an enum later
const horses = [];
@@ -79,6 +73,8 @@ function runRace(ctx,bg_ctx){
const y = HEIGHT / 2;
const lane_1_height = HEIGHT - (horseHeight * 1.25);
//todo- change these sway varibles to be "trot" objects, or something, at put it in a horse object, so we can reuse these better
// horse 1 & 2 are hilarious, horse 3&4 are more normal paced
const horse_1_sway = Math.sin(framecount) * 10;
const horse_1_X_sway = Math.cos(framecount/3) * 10;
@@ -108,11 +104,11 @@ function initHorses() {
console.log("initHorses");
for (let i =0; i < 4; i ++ ){
const horse_image = new Image();
horse_image.src = horse_image_array[i]; // todo - change to grab random horse image
horse_image.src = horse_image_array[i]; // todo - change to grab random horse
horse_image.onload = function() {
const horse = {
image: horse_image
// todo - Draw the rest of the fucking owl
// todo - other horse things.
}
horses.push(horse);
console.log("horseImagePushed");