Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Diana
    @dianapham
    yup. check out this page. just skim it: http://www.w3schools.com/js/js_properties.asp
    Diana
    @dianapham
    to possibly further confuse you, you can also create parameters from properties.
    Kim Cole
    @kcole009
    yeah that's dr.seuss talk at this point
    Diana
    @dianapham
    i was deprived as a child, i don't understand that reference
    Kim Cole
    @kcole009
    hmm...creative man who used a lot of alliteration and rhymes?
    Diana
    @dianapham
    oh i know who he is, i just don't understand any inside jokes or references coming from his character or his stories
    Kim Cole
    @kcole009
    gotcha
    just the alliteration reminded me
    Diana
    @dianapham
    tbh i'm getting bored of just going over concepts. how about we all just build a bunch stuff during lab today and we can learn the concepts along the way? i wanna show y'all how to get javascript and html working together. or you know, whatever. yeahhhh.
    Kim Cole
    @kcole009
    yes please, I feel so behind not applying all of these things
    Diana
    @dianapham
    good to know we're on the same page. i'll prepare a bunch of simple projects then.
    Diana
    @dianapham
    Uptown Espresso Inc, 500 Westlake Ave N, Seattle, WA 98109
    Diana
    @dianapham
    Apparently, the lab is open now if anyone prefers to go there. I'm still going to be at Uptown Espresso until 6pm.
    Emily Doherty
    @edohert
    Does anyone have the code from brook's race game last night? The one i typed isn't working...
    Paulsvh
    @Paulsvh
    Yup
    Hang on
    <script>
    function Animal(name, speed, focus) {
    this.name = name;
    this.speed = speed;
    this.focus = focus; // Values: 0 - 9
    this.position = 0;
    this.isFocused = function() {
    return Math.floor(Math.random() * 10) < this.focus
    }
    this.advance = function() {
    if (this.isFocused()) {
    this.position += this.speed;
    }
    }
    this.progressReport = function() {
    return this.name + " is at: " + this.position
    }
    }

    var rabbit = new Animal("Jack", 10, 1);
    var turtle = new Animal("Yurtle", 2, 10);
    var meters = 100;

    while (rabbit.position < meters && turtle.position < meters) {
    rabbit.advance();
    turtle.advance();
    alert(rabbit.progressReport() + " | " + (turtle.progressReport()));
    }

    //alert(rabbit.progressReport());
    //alert(turtle.progressReport());
    </script>
    Emily Doherty
    @edohert
    Thank you!
    Chris Copley
    @chriscopley
    Hey, how can I run code like the above to check it? Another programmer said he uses an IDE. Which also flags errors.
    Diana
    @dianapham
    You can either put it in an HTML file and open it in a browser or you can take everything in between the script tags ans put it into a console (google > developer tools > console)
    google chrome*
    Chris Copley
    @chriscopley
    Thanks. My son had an idea. He suggested putting alerts in the code at the end of each paragraph. The alerts basically say "So far, so good" with a local reference. Helped me locate the problem in my code.
    Chris Copley
    @chriscopley
    @dianapham Trying to build my race game (late, I know) and it won't execute. I simplified it, to reduce potential error. But it's still not running.
    Screen Shot 2014-09-17 at 8.33.41 AM.png
    Sorry. Trying to add a screen shot.
    Diana
    @dianapham
    lemme see the rest of the code
    Chris Copley
    @chriscopley
    I'm in the process of revising it to simplify it (so it works in the first place). But I haven't gone through the entire thing to simplify. So the second half of it still has remnants of my first concept: a gun-shooting spaceship race. Would that be a problem?
    Here's the full code as it stands:
    <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>
    Diana
    @dianapham
    you've got some semicolon and bracket issues. comb through your code and see if you can fix those.
    Chris Copley
    @chriscopley
    Thanks. I'm still not clear on those either, obviously.
    @dianapham I revised my page rebuild, BTW.
    Diana
    @dianapham
    okay paste it here. there's a little rectangular box with lines on the bottom right corner of the typing box. it'll show you shortcuts on how to add code to this chat
    Chris Copley
    @chriscopley
    Paste the race game? or the page rebuild?
    Diana
    @dianapham
    either. if the page rebuild is good, just resubmit it on canvas.
    Chris Copley
    @chriscopley

    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>

    Chris Copley
    @chriscopley
    Not sure why only some of the code appears as code.
    Diana
    @dianapham
    @chriscopley sorry for the delay. i've been sick in bed.
    right before you create "this.advance = function ....." you have a closing curly brace.
    that means you're closing the Spaceship
    all yoru other properties aren't part of Spaceship now
    Chris Copley
    @chriscopley
    Sorry you're not feeling well.
    I copied that part of the code from what Brook wrote, but then I modified it. Clumsily, apparently. OK, so I'll take out that bracket.
    Chris Copley
    @chriscopley
    The code still doesn't launch.
    Diana
    @dianapham
    when you're creating new spaceships, i notice you've got 3 values. in your initial spaceship constructor, you're only asking for two values.
    @chriscopley go ahead and grab one of the TAs in class right now since they'll be able to sit next to you and go over the code. sorry i couldn't be there.
    Chris Copley
    @chriscopley
    I did. I sat with Dale, I think. The older TA. He didn't know JS real well, but did help with syntax. Got the thing to run. But my spaceships don't advance. I don't know how to add this.position and this.speed. The + apparently doesn't do it. Or I need parens. Or something.
    Feeling better?