Tuesday, May 28, 2019

Car Builder

Car Builder (1982 Simulation Game)



Find Acs-Hand-Out \ IT \ #Tools \ CarBuild - copy to your onedrive
 
In order to run Car Builder 
you will require: DOSBox for Google chrome
INSTRUCTIONS TO LOAD DOSBox

Search for it and load it. After loading it you should see an APPS section in the bookmark bar. 


INSTRUCTIONS TO LOAD CAR BULDER

  1. Launch the Chrome app
  2. Click the ? in the bottom right corner of the DOSBox window
  3. LOOK TOP RIGHT Choose to: Delete C:\ drive contents
  4. CLICK ON: Import local directory to C:\ drive
  5. Find your onedrive CarBuild - click OK
  6. SHUT down then Restart APP
IF --> the screen pops up all black
go to ? - choose configure DOSBox (Advanced)
place a '#' infront of output=opengl    ---   # output=opengl
click SAVE
  1. Type: cd carbuild
  2. Type: car
Grading Rules:
  • All cars must have a body.
  • Point System     C  B  A    (BONUS: A+ on the fastest cars - if you are the only person)
  • NOTE   C-   B-    A-    if you omit your blog URL or decal or both
  • Your points may change with the latest results. Be prepared to adjust your car.



FOUR DAY project
  • Build your car
  • All cars must have a body
  • Test your car
  • ALWAYS add your name as a DECAL
  • Screenshot, resize then add URL
  • POST with title describing the car and goal
  • Under the image place a caption for which car it is and the goal you were trying for especially if you are posting more than 1 screenshot in a post.
  • for example  "100 mph car 4 seats" or "Fastest Sedan (4 seats) 177 mph"

DAY 1:

  • 100 mph car (2) seats
  • Slowest car 2 seats 53 mph
  • fastest minivan (6 seats ) 166 mph
Post: 3 cars with captions
DAY 2:

  • 100 mph sedan (4) seats
  • Slowest minivan (6) seats 45 mph
  • fastest sedan (4) seats 177 mph
Post: 3 cars with captions
GOALS
A:   100 mph car 2/4/6 seats
B:   +- 1 mph
C:   +- 2 mph
GOALS
A:   slowest car  2/4/6 seats
B:   + 1 of slowest speed
C:   + 2 of slowest speed
DAY 3:

  • 100 mph Minivan (6) seats
  • Slowest Sedan (4) seats 45 mph
Post: 2 cars with captions
DAY 4:
  • Fastest Car (2) seats 195mph


Post : 1 car with caption
GOALS
A:   fastest 6/4 seats car
B:   within 10 mph of fastest car
C:   within 20 mph of fastest car
GOALS
A:  Fastest 2 seat car
B:  within 20 of fastest car
C:  within 40 of fastest car

Friday, May 24, 2019

Animate CC - Pong Game Part 5 & Part 6 -collisions

Animate CC - Pong Game 
Part 5 & Part 6



Part 5 -Collisions


If the ball and the playerPaddle share the same space then the ball’s speed is reversed by multiplying by -1 (do you remember the maze game?)

This code goes just above of the other code in the function loop. It tests to see if the ball is moving left (negative number that is < 0) so the ball does not get stuck behind the paddle. The CPU paddle is treated similarly. Except the ball will be moving to the right or have a positive value…so we test for that.
hit F9

The Code:

if( playerPaddle.hitTestObject(ball) == true ){
    if(ballSpeedX < 0){
        ballSpeedX *= -1;
    }

} else if(cpuPaddle.hitTestObject(ball) == true ){ //add this
    if(ballSpeedX > 0){
        ballSpeedX *= -1;
    }

}

Do not forget the last bracket!




Part 5b
Now to add some functionality. This first function tests for ball angle and sets the y speed to a number between 5 and -5 depending on where on the paddle it hits. Add this function above the function loop NOT inside the loop like the others.

THE CODE:

function calculateBallAngle(paddleY:Number, ballY:Number):Number
{
    var ySpeed:Number = 5 * ( (ballY-paddleY) / 25 );
    // (ballY-paddleY) / 25 will be between -1 and 1 depending on where the ball hits

    return ySpeed;
}

Do not forget this last bracket.
 Now REPLACE the playerPaddle and cpuPaddle hitTestObject code we just added (in 5 above) with this

The CODE:

if( playerPaddle.hitTestObject(ball) == true ){
    if(ballSpeedX < 0){
        ballSpeedX *= -1;
        ballSpeedY = calculateBallAngle(playerPaddle.y, ball.y); //add this
    }

} else if(cpuPaddle.hitTestObject(ball) == true ){
    if(ballSpeedX > 0){
        ballSpeedX *= -1;
        ballSpeedY = calculateBallAngle(cpuPaddle.y, ball.y); //add this
    }

}

Do not forget this last bracket.



Part 06 –scoring points
Start with ZERO, if you miss a ball the other gets a point.
Add these variable where the others are –at the very top-:
THE CODE:

var playerScore:int = 0;
var cpuScore:int = 0;

now add points – look for the following code then make these changes:

the CODE:

//first check the left and right boundaries
if(ball.x <= ball.width/2){ //check if the x position
      ball.x = ball.width/2; //then set the ball's x position
      ballSpeedX *= -1; //and multiply the ball's x speed by -1
      cpuScore ++; //increase cpuScore by 1
} else if(ball.x >= stage.stageWidth-ball.width/2){ //check to see if         ball.x = stage.stageWidth-ball.width/2; //and set the         
      ballSpeedX *= -1; //multiply the x speed by -1
      playerScore++; //increase playerScore by 1     
}

This will not show up anywhere. We need to add a display for the scores. Note the capitals!
With the text tool write Player Score: 0 – check its properties and set to Dynamic Text and instance name to: playerScoreText
Again:
Write CPU Score: 0 –dynamic text – instance name: cpuScoreText
Add a new function – above the other new function (ball angle)
To avoid an error message we need to add a font
Choose – TEXT –Font Embedding
Find your font –check box uppercase, lowercase and numerals

– click the + sign (top left ish)
we added
Here’s the code:

function updateTextFields():void
{
    playerScoreText.text = ("Player Score: " + playerScore);
    cpuScoreText.text = ("CPU Score: " + cpuScore);
}

Do not forget the last bracket.
Make some changes to your code again:
FIND the CODE:

//first check the left and right boundaries
if(ball.x <= ball.width/2){ //check if the x position               
    ball.x = ball.width/2; //then set the ball's x position                      
    ballSpeedX *= -1; //and multiply the ball's x speed                      
    cpuScore ++; //increase cpuScore by 1
    updateTextFields();
} else if(ball.x >= stage.stageWidth-ball.width/2){ //check to see if            
    ball.x = stage.stageWidth-ball.width/2; //and set the x position to that,               
    ballSpeedX *= -1; //multiply the x speed by -1 so that the ball is now moving left
    playerScore++; //increase playerScore by 1
    updateTextFields();
}

CTRL-ENTER to play
WINDOW KEY + G to record
download as an animated GIF



=ALL DONE=

Animate CC - Pong Game -Part 3 & Part 4 - paddle code

Animate CC - Pong Game 
Part 3 & Part 4
-paddle code-



Pong Part 3 – the Player’s Paddle

In this section, you simply add code to make the player’s paddle move. It moves up and down according to your mouse movement. Code also stops it from exiting the screen.
Add this code to  à
function loop(e:Event):void
{
    Right about here   
          ball.x += ballSpeedX;
the code: press F9 to bring up the actions window

playerPaddle.y = mouseY;

// check if top of paddle is above top of screen
if(playerPaddle.y - playerPaddle.height/2 < 0){
     playerPaddle.y = playerPaddle.height/2;

//check if bottom of paddle is below bottom of screen
} else if(playerPaddle.y + playerPaddle.height/2 > stage.stageHeight){
     playerPaddle.y = stage.stageHeight - playerPaddle.height/2;
}


don't miss this last bracket

CTRL-ENTER to play
WINDOW KEY + G to record
upload - https://ezgif.com/
download as an animated GIF


  
NOTE: left paddle follows the mouse (vertically)

Pong Part 4 – the CPU's Paddle


Part 4 –the CPU’s paddle

This code is meant to simulate a decent paddle player.  The CPU should miss occasionally because it will be a little too slow.
The first bit of code is placed at the very top just under var ballSpeedY:int = -2;
The CODE:

var cpuPaddleSpeed:int = 3;

The next bit of code where we place the rest of the code – in the function loop
Place it just above playerPaddle.y = mouseY;

The CODE

if(cpuPaddle.y < ball.y - 10){
    cpuPaddle.y += cpuPaddleSpeed;
} else if(cpuPaddle.y > ball.y + 10){
    cpuPaddle.y -= cpuPaddleSpeed;
}

Do not forget the very last bracket!


CTRL-ENTER to play
WINDOW KEY + G to record
download as an animated GIF








Wednesday, May 22, 2019

Animate CC - Pong Game -Part 1 & Part 2 -setup - ball

Animate CC - Pong Game
Part 1 and Part 2

Pong Part 1 -setup the stage
https://as3gametuts.com/2011/03/19/pong-1/

Actionscript 3.0 – stage: black – FPS: 60 – W 550xH 400
Ball (white is optional)
- edit the symbol and make the ball spin in 20 frame
Draw a (white) circle – hold shift key – in properties –set size to 10x10
– convert to symbol – ‘Ball’ – movie clip
Paddle

Draw a vertical (white) rectangle – in properties – set size to W:10 x H: 50
– convert to symbol –‘paddle’ – movie clip
-duplicate symbol

-edit each paddle symbol and make the colours blink(#1) and change(#2)
Add an extra paddle to the stage – drag from library
Position these items on the stage
In properties of the:
Paddle left (X: 20 Y: 200)
Ball (X: 275 Y: 200)

Paddle right (X: 530 Y: 200)

  


Pong Part 2 - the ball moves



Name your games pieces:
Paddle left : -in properties- <instance name>: playerPaddle – note the capital P for Player
Paddle Right : -in properties- <instance name>: cpuPaddle – note the capital P for Player
Ball : -in properties- <instance name>: ball – note the lower case b for ball
ADD the CODE
CLICK ON THE BALL – press F9
Paste the following
var ballSpeedX:int = -3;
var ballSpeedY:int = -2;

init();

function init():void
{
    stage.addEventListener(Event.ENTER_FRAME, loop);
}

function loop(e:Event):void
{
    ball.x += ballSpeedX;
    ball.y += ballSpeedY;

    //because the ball's position is measured by where its CENTER is...
    //...we need add or subtract half of its width or height to see if that SIDE is hitting a wall

    //first check the left and right boundaries
    if(ball.x <= ball.width/2){ //check if the x position of the left side of the ball is less than or equal to the left side of the screen, which would be 0
        ball.x = ball.width/2; //then set the ball's x position to that point, in case it already moved off the screen
        ballSpeedX *= -1; //and multiply the ball's x speed by -1, which will make it move right instead of left

    } else if(ball.x >= stage.stageWidth-ball.width/2){ //check to see the right side of the ball is touching the right boundary, which would be 550
        ball.x = stage.stageWidth-ball.width/2; //reposition it, just in case
        ballSpeedX *= -1; //multiply the x speed by -1 (now moving left, not right)

    }

    //now we do the same with the top and bottom of the screen
    if(ball.y <= ball.height/2){ //if the y position of the top of the ball is less than or equal to the top of the screen
        ball.y = ball.height/2; //like we did before, set it to that y position...
        ballSpeedY *= -1; //...and reverse its y speed so that it is now going down instead of up

    } else if(ball.y >= stage.stageHeight-ball.height/2){ //if the bottom of the ball is lower than the bottom of the screen
        ball.y = stage.stageHeight-ball.height/2; //reposition it
        ballSpeedY *= -1; //and reverse its y speed so that it is moving up now

    }
}

-add your name and a title on a different layer
Now: Type CTRL-ENTER to test
Use WINDOW KEY + G – record your part 2 stage in action

Upload to https://ezgif.com/ convert to a GIF and Post it.





https://as3gametuts.com/2011/08/31/pong-3/

https://as3gametuts.com/2011/09/13/pong-4/

https://as3gametuts.com/2011/09/24/pong-5/

https://as3gametuts.com/2011/09/28/pong-6/