-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thursday July 30, 2015 #1
Closed
Changes from 10 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
34f36af
basic html for layout
cbotwell 6a80979
added basic scss imports and updated Brocfile
cbotwell 68481b4
started basic styles
cbotwell 82823b1
started constructors, added characters and template
cbotwell b51ec54
got templates for game screens set up and calling the battle screen
cbotwell 3f33988
got start screen populating cages and changed to battle screen
cbotwell 574d233
got currentEnemy and currentHero showing on battle screen
cbotwell 04248fb
got health bar showing up, working on making health update
cbotwell d46026d
attacking updates health, working on turns
cbotwell 0720a19
trying to make turns and get gameover screen
cbotwell 7a070c2
passed game object to newBattle to remove extra variables
cbotwell b38362e
passing game object to battle template
cbotwell 0493fbc
game goes to end screen when a character dies
cbotwell 7894255
added play again button, not reseting health
cbotwell c2e278c
added notes
cbotwell 29cdfc6
git healthbar for enemy working
cbotwell c20375c
added castor picture
cbotwell fb270cf
deploying
cbotwell bdb2184
added artwork
cbotwell c39b30d
artwork
cbotwell 5e68d9c
fixed benjamin gates pic
cbotwell a4c3bad
fixed bg
cbotwell dbbab90
got enemy selecting randomly with _.sample
cbotwell b1a58f1
random enemy
cbotwell a1e9994
got AI attacking, but not on odd turns, hero health bar updates
cbotwell f4c40b0
AI attacks
cbotwell 5aa38b3
moved renderBattle and renderHealth to game object
cbotwell 2a9b8da
changed name to renderHealth
cbotwell c3e89c7
moved render health under render battle to simplify new battle
cbotwell 0e678f2
updates
cbotwell 0166f52
woking on game prototypes
cbotwell 49b4d35
added comment for trigger
cbotwell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
castorTroy = new Character({name: 'Castor Troy', weapons: {dualGoldenGuns: 40}, weaponName: 'Dual Golden Guns', hitPoints: 100, imgUrl: 'nic.png'}); | ||
memphisRaines = new Character({name: 'Memphis Raines', weapons: {eleanor: 60}, weaponName: 'Eleanor', hitPoints: 100, imgUrl: 'nic.png'}); | ||
benjaminGates = new Character({name: 'Benjamin Gates', weapons: {declarationOfIndependence: 50}, weaponName: 'Declaration of Independence', hitPoints: 100, imgUrl: 'nic.png'}); | ||
johhnyBlaze = new Character({name: 'Johnny Blaze', weapons: {chain: 30}, weaponName: 'Chain', hitPoints: 100, imgUrl: 'nic.png'}); | ||
|
||
var heros = [castorTroy, memphisRaines, benjaminGates, johhnyBlaze]; | ||
|
||
$('.game-target').html(AppTemplates.start(heros)); | ||
|
||
function Game(hero) { | ||
this.hero = hero; | ||
this.enemy = johhnyBlaze; | ||
this.turnNumber = 0; | ||
this.gameOver = false; | ||
} | ||
|
||
var selectCharacterEl = $('.select-character'); | ||
|
||
var heroTargetEl = []; | ||
var enemyTargetEl = []; | ||
|
||
var renderHero = function(hero) { | ||
heroTargetEl.html(AppTemplates.character(hero)); | ||
}; | ||
|
||
var renderEnemy = function(enemy) { | ||
enemyTargetEl.html(AppTemplates.character(enemy)); | ||
}; | ||
|
||
var attackButtonEl = []; | ||
|
||
var healthBar = []; | ||
|
||
var newBattle = function() { | ||
$('.game-target').html(AppTemplates.battle()); | ||
|
||
heroTargetEl = $('.hero-target'); | ||
enemyTargetEl = $('.enemy-target'); | ||
renderHero(currentHero); | ||
renderEnemy(currentEnemy); | ||
|
||
healthBar = $('.hpbar'); | ||
healthBar.width(currentHero.getHealth + '%'); | ||
|
||
attackButtonEl = $('.attack'); | ||
attackButtonEl.html(currentHero.weaponName); | ||
|
||
attackButtonEl.on('click', function() { | ||
currentHero.attack(currentEnemy, 'dualGoldenGuns'); | ||
renderHero(currentHero); | ||
renderEnemy(currentEnemy); | ||
|
||
healthBar.width(currentEnemy.getHealth + '%'); | ||
turn++; | ||
}); | ||
|
||
if (turn % 2 === 1) { | ||
currentEnemy.attack(currentHero, 'chain'); | ||
renderHero(currentHero); | ||
renderEnemy(currentEnemy); | ||
|
||
healthBar.width(currentEnemy.getHealth + '%'); | ||
turn++; | ||
} | ||
|
||
if (currentHero.getHealth <= 0 || currentEnemy.getHealth <= 0) { | ||
$('.game-target').html(AppTemplates.gameover()); | ||
} | ||
}; | ||
|
||
var currentHero = {}; | ||
var currentEnemy = {}; | ||
var turn = 0; | ||
|
||
selectCharacterEl.on('click', function() { | ||
var indexSelected = $(this).data('index'); | ||
var hero = heros[indexSelected]; | ||
var game = new Game(hero); | ||
currentHero = game.hero; | ||
currentEnemy = game.enemy; | ||
turn = game.turnNumber; | ||
|
||
newBattle(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
function Character(options) { | ||
options = options || {}; | ||
var hitPoints = options.hitPoints || 100; | ||
this.weapons = options.weapons || {}; | ||
this.weaponName = options.weaponName; | ||
this.name = options.name; | ||
this.imgUrl = options.imgUrl; | ||
|
||
this.takeDamage = function(damage) { hitPoints -= damage; }; | ||
|
||
this.getAttackStrength = function(weaponName) { | ||
if (this.weapons[weaponName]) { | ||
return this.weapons[weaponName]; | ||
} | ||
|
||
return 5; | ||
}; | ||
|
||
this.on('attacked', function(amount) { | ||
this.takeDamage(amount); | ||
}); | ||
|
||
this.getHealth = function() {return hitPoints;}; | ||
} | ||
|
||
Character.prototype = _.extend({ | ||
constructor: Character, | ||
|
||
attack: function(hostile, weapon) { | ||
hostile.trigger('attacked', this.getAttackStrength(weapon)); | ||
} | ||
|
||
}, Backbone.Events); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
// imported and box sizing | ||
|
||
@import 'reset'; | ||
|
||
$fa-font-path: "//netdna.bootstrapcdn.com/font-awesome/4.3.0/fonts"; | ||
@import 'font-awesome'; | ||
@import url(http://fonts.googleapis.com/css?family=Press+Start+2P); | ||
|
||
@import 'bourbon'; | ||
@import 'neat'; | ||
|
||
html { | ||
box-sizing: border-box; | ||
} | ||
*, *:before, *:after { | ||
box-sizing: inherit; | ||
} | ||
|
||
// variables | ||
|
||
$font-defaults: Helvetica, Arial, sans-serif; | ||
$video-game-font: 'Press Start 2P', cursive; | ||
$main-color: ; | ||
$alt-color: ; | ||
$main-border: 3px solid black; | ||
|
||
// starting styles | ||
body { | ||
font-family: $video-game-font; | ||
} | ||
.center { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
|
||
@include outer-container; | ||
width: 980px; | ||
} | ||
.start { | ||
h1 { | ||
font-size: 3em; | ||
text-align: center; | ||
margin-bottom: 30px; | ||
} | ||
button { | ||
font-family: inherit; | ||
padding: 10px; | ||
} | ||
.characters { | ||
@include outer-container; | ||
} | ||
.character { | ||
@include span-columns(3); | ||
@include omega(4n); | ||
text-align: center; | ||
p { | ||
margin: 20px 0; | ||
} | ||
img { | ||
width: 100%; | ||
} | ||
} | ||
|
||
} | ||
.battle { | ||
.hero-target, .enemy-target { | ||
@include span-columns(6 of 12); | ||
text-align: center; | ||
padding: 10px; | ||
img { | ||
width: 75%; | ||
} | ||
.hp { | ||
margin: 10px; | ||
} | ||
.hpborder { | ||
margin: 10px; | ||
border: $main-border; | ||
@include span-columns(10); | ||
@include shift(1); | ||
height: 10px; | ||
} | ||
.hpbar { | ||
background: red; | ||
height: 5px; | ||
} | ||
} | ||
.messages { | ||
@include span-columns(12); | ||
|
||
border-radius: 5px; | ||
border: $main-border; | ||
padding: 1px; | ||
.fight { | ||
border-radius: 5px; | ||
border: $main-border; | ||
padding: 10px; | ||
min-height: 100px; | ||
position: relative; | ||
} | ||
.fa-play { | ||
position: absolute; | ||
top: 50%; | ||
left: 30px; | ||
transform: translateY(-50%); | ||
} | ||
button { | ||
font-family: inherit; | ||
padding: 10px; | ||
position: absolute; | ||
top: 50%; | ||
left: 50px; | ||
transform: translateY(-50%); | ||
border: none; | ||
background: none; | ||
} | ||
} | ||
} | ||
.gameover { | ||
text-align: center; | ||
h1 { | ||
font-size: 3em; | ||
margin-bottom: 20px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<div class="center"> | ||
<div class="battle"> | ||
<div class="characters"> | ||
<div class="hero-target"></div> | ||
<div class="enemy-target"></div> | ||
</div> | ||
<div class="messages"> | ||
<div class="fight"> | ||
<i class="fa fa-play"></i> | ||
<button class="attack">Attack</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<img src="{{ imgUrl }}" alt="{{ name }}"> | ||
<p>{{ name }}</p> | ||
<div class="hp"> | ||
<p>HP: {{ getHealth }}</p> | ||
<div class="hpborder"> | ||
<div class="hpbar"></div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="center"> | ||
<div class="gameover"> | ||
<h1>CAGE WINS!</h1> | ||
<p> | ||
"I don't think movies are the reason why this violence exists, I think it's going to happen whether movies are there or not." - Nicolas Cage | ||
</p> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<div class="center"> | ||
<div class="start"> | ||
<h1>CAGE MATCH</h1> | ||
<div class="characters"> | ||
{{#each this as |cage|}} | ||
<div class="character"> | ||
<img src="{{ cage.imgUrl }}" alt="{{ cage.name }}"> | ||
<p>{{ cage.name }}</p> | ||
<button class="select-character" data-index="{{@index}}"> Select</button> | ||
</div> | ||
{{/each}} | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of having a
game
object is so that it stores and manages your hero, enemy, turn number, etc.Try to pass your
game
as an argument to thenewBattle
function and this will clear up thecurrentHero
,currentEnemy
variables everywhere.