OK. Here's the race game<script>
// I want to create a game in which one competitor can eliminate another. In this case, a spaceship "race." Kind of like something from "Star Wars." But because I still don't know what I'm doing, I'm trying to build a stupidly simple race game to start with. But my code is not running
function Spaceship(name, speed) {
this.name = name;
// Values 0 - 9 for speed
this.speed = speed;
this.position = 0;
alert("successfully set params")
}
this.advance = function() {
return this.position + this.speed;
alert("successfully set advance")
}
}
this.progressReport = function() {
return this.name + " is at " + this.position
}
}
var freighter = new Spaceship("Big Mac", 5, 4);
alert("successfully set Big Mac")
var battleship = new Spaceship("Warhorse", 2, 9);
alert("successfully set Warhorse")
var passengerLiner = new Spaceship("Space Duck", 7, 1);
alert("successfully set Space Duck")
var meters = 50;
alert("successfully set meters")
while ((freighter.position < meters && battleship.position < meters) && passengerLiner.position < meters) {
freighter.advance();
battleship.advance();
passengerLiner.advance();
alert(freighter.progressReport() + " | " + battleship.progressReport() + " | " passengerLiner.progressReport());
}
</script>
@chriscopley i finally debugged your code. basically i had to rewrite the whole thing from scratch to see what the differences where.
fix those things and let me know if it works. i've rewritten yours a few times just fixing those errors and it seems to work now. the += was what really caused the lack of advancement.
yeah, i'm planning on being at lab tonight. and yes, i want to go over css and jquery. i'm waiting for brook to post the slides from yesterday so i can see what you guys went over. was there anything specific you wanted to review for jquery?
(fyi. i'll probably smell like cough drops all night.)