Code for week 9

This is the code for astroids

Planetoids code

x = 375;
y = 250;

vx = 0;
vy = 0;

deltaVx = 0;
deltaVy = 0;

theta = 0;

Fthrust = 30.0;
mass = 4.5;
dt = 0.1;

function draw(){
// Update velocities
vx += deltaVx;
vy += deltaVy
// Update location
x += vx*dt;
y += vy*dt;
// velocity is unchanged if there are no forces
deltaVx = 0;
deltaVy = 0;
// Turn or thrust the ship depending on what key is pressed
if (keyIsDown(LEFT_ARROW)) {
theta += 0.1;
}
if (keyIsDown(RIGHT_ARROW)) {
theta += -0.1;
}
x = 375;
y = 250;

vx = 0;
vy = 0;

deltaVx = 0;
deltaVy = 0;

theta = 0;

Fthrust = 30.0;
mass = 4.5;
dt = 0.1;

function draw(){
// Update velocities
vx += deltaVx;
vy += deltaVy
// Update location
x += vx*dt;
y += vy*dt;
// velocity is unchanged if there are no forces
deltaVx = 0;
deltaVy = 0;
// Turn or thrust the ship depending on what key is pressed
if (keyIsDown(LEFT_ARROW)) {
theta += 0.1;
}
if (keyIsDown(RIGHT_ARROW)) {
theta += -0.1;
}
if (keyIsDown(UP_ARROW)) {
// Rockets on!
accelx = Fthrust*cos(theta)/mass;
deltaVx = accelx*dt;
accely = Fthrust*sin(theta)/mass;
deltaVy = accely*dt;
}
if (keyIsDown(DOWN_ARROW)) {
accelx = -Fthrust*cos(theta)/mass;
deltaVx = accelx*dt;
accely = -Fthrust*sin(theta)/mass;
deltaVy = accely*dt;
}
if (keyIsPressed && key == ‘ ‘){ //spacebar
// Do nothing!
}

// Draw ship and other stuff
// This will clear the screen and re-draw it
display();
{

Blog code

strong>Week 9 blogging challenge</strong>

For this weeks blogging challenge we did coding. For the first task we had to read a story about a teen named Alex I really liked his story it was inspirational and was also very interesting. The second thing we had to do was to leave a comment so I did. He hasn’t responded yet but I hope he will.

For the second task I had to do an hour of code so I went to the website <a href=“https://hourofcode.com/ca”> hour of code </a> to try to find a cool task a ton of the tasks were all block coding but I wanted to try something else like java script or HTML. In the end I found a super cool one where I got to code asteroids the game. This required that I used the arrow keys on my keyboard which was fine because I had them but one of my friends named <a href=”“http://www.blog44.ca/andersb/”Anders”> Anders </a>didn’t have a keyboard so we ended up working on this together. It was really fun so what we had to do was fix problems with the code in order to make the ship fly around and dodge the asteroids. It wasn’t to hard except for the fact that I always forgot to capitalize which is super important because if you don’t well then it doesn’t work. Some of the things we had to fix were turning, what direction you moved, and how fast you moved the hardest out of those three was definitely what direction you moved because it took the most code to fix. This hole experience took around an hour ten minutes.

The final task was to use HTML on your blog so you all are looking at exactly what I did right now but in case you are still curious I will make another <a href=”https://www.blog44.ca/matthewt/2018/12/07/408/”>blog post where I just show the code I used for this blog and astroids </a> I hope you like what I did.

Over all I think this was an amazing experience my favourite part had to be working on asteroids with my friend <a href=”Blog44.ca/andersb”> Anders </a> because astroids is a awesome game and it was fun to mess around with a friend while coding. One thing that I would change if I were to do this again is to maybe try something a little bit harder that astroids like maybe trying some python or c++. That was my week 9 blogging challenge hope you liked it.

Leave a Reply

Your email address will not be published. Required fields are marked *