Digital and Interactive Games 2015, Term 2, Week 9, Session 1
Mastermind continued


Today:

int correctPlace = 0;
int correctColour = 0;

if new(i) = puzzle(i)
    correctPlace++;

http://i483.photobucket.com/albums/rr193/Brenorenz/W17001_zpsdsllhcqn.png

Square.cpp

#include "Square.h"


Square::Square()
{
    DrawingObject::DrawingObject();
}

void Square::setUp(float size, ID2D1SolidColorBrush* brush) {
    this->size = size;
    setLocation(halfSize, halfSize);
    setBrush(brush);
    setActive(true);
}

void Square::setLocation(float x, float y) {
    location.x = x;
    location.y = y;
    rect = D2D1_RECT_F(/*
        D2D1::Point2F(location.x, location.y),
        location.x - halfSize, location.y - halfSize, location.x + halfSize, location.y + halfSize*/
        );
}

void Square::update(GameTime gameTime) {
    velocity.setX(velocity.getX() + getAccelerationX());
    velocity.setY(velocity.getY() + getAccelerationY() + getGravity());
    setLocation(static_cast(location.x + velocity.getX() * static_cast(gameTime.getElapsedTime())),
        static_cast(location.y + velocity.getY() * static_cast(gameTime.getElapsedTime())));
}

void Square::draw(ID2D1HwndRenderTarget* renderingTarget) {
    renderingTarget->DrawRectangle(rect, brush, strokeWidth);
    renderingTarget->FillRectangle(rect, brush);
}

Square::~Square()
{
}


BaseApp.h
#include “Square.h”


Mastermind.java
image.Background

background = new image(“media/Mastermind 002.png”)

#cplusplus #gamedesign   #gameprogramming   #java   #mastermind   #programming   #tafe  
Digital and Interactive Games 2015 – Term 2, Session 1
Java
IDE – Eclipse for Java
Programming Minecraft in Term 3
This term – Basic Java
Java – can be used in other OS's for creating user interfaces

Dungeon Game
–    character (hero)
–    Next week: collision detection routine


Today
Setup Eclipse
Intro to Java

JavaFX

Read and Write files

Other half of the time
C++

Minecraft
–    minigame

Still need to use Bitbucket

Intro to Java
–    Download Eclipse
Not Microsoft, Apple or Google
Oracle
It is used extensively on Android

Misconception – Java on Windows – vector for viruses

Senior Programmer A$90,000 per year
Junior Programmer A$65,000 per year
More jobs in Europe.

Java a Beginner's Guide (6th Edition)

Other option – Netbean (Oracle)

Eclipse – open source

–    Create New Project
New Java Project
First Program
JRE – JavaSE- 1.8
No need for working sets – until we work on Minecraft.
New Class
Package
au.com.nsct.first
or
com.hotmail.fardell24.first
or
com.gmail.brenorenz30.first

Name
FirstProgram (Pascal casing)
Public
/ public static void main (string[] args) – using console
Finish


// Print test message
System.out.Println(“Test String”);

Important to document

Second Program

int a = 5;
int b = 3;

System.out.Println(a + b);


int sum = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10;

System.out.Println(sum);

Loops

(C++)
for (int i = 0; i != 10; ++i) {

}

Java
for (int i = 0; i < 10; ++i) {

}

(0, 10]

for (int i = 0; i < 10; ++i) {
    sum;
}

2147483647
64 bit int overflow
Formula – sum of 1 to n
n(n + 1)
---------
      2

Third Project

int sum = 0;
int n = 10;
sum = (n * (n + 1)) / 2;

System.out.Println(sum);


ParseInt


int sum = 0;
int n = 10;

if (args.length = 0) {
    n = Integer.parseInt(args[0]);
}

sum = (n * (n + 1))/ 2;
System.out.Println(sum);
System.out.Println(args.length);
Scope and lifetime of variables

i483.photobucket.com/albums/rr…

System.out.Print(“A”);


for (int x = 0; x < 5; x++) {
    System.out.Print(“A”);
}


for (int x = 0; x < 5; x++) {
    for (int y = 0; y < 5; y ++) {
        System.out.Print(“A”);
    }
}



* / + -
% - mod – returns a remainder.

for (int x = 0; x < 5; x++) {
    for (int y = 0; y < 5; y ++) {
        if (y % 2 == 0)
            System.out.Print('A');
        else
            System.out.Print(' ');
    }
    System.out.Println();
}
for (int x = 0; x < 5; x++) {
    for (int y = 0; y < 5; y ++) {
        if (x % 2 == 0) {
            if (y % 2 == 0)
                System.out.Print('A');
            else
                System.out.Print(' ');
        }
        else {
            if (y % 2 == 1) {
                System.out.Print(' ');
            else
                System.out.Print('A');
        }
    }
}

i483.photobucket.com/albums/rr…

Pass in row size
Pass in column size
Declare first variable (x – row)
Declare second variable (y - column)

Ask for number of rows
Get number of rows
Ask for number of columns
Get number of columns

x Loop (using number of rows)
.    y Loop (using number of columns)
.    .    if (x = 1)
.    .    .    if (y = 1)
.    .    .    .    Print 'X'
.    .    .    if else (y = n)
.    .    .    .    Print 'X'
.    .    .    else
.    .    .    .    Print ' '
.    .    if else (x = n)
.    .    .    if (y = 1)
.    .    .    .    Print 'X'
.    .    .    if else (y = n)
.    .    .    .    Print 'X'
.    .    .    else
.    .    .    .    Print ' '
.    .    else
.    .    .    if (y = 1)
.    .    .    .    Print ' '
.    .    .    if else
.    .    .    .    Print ' '
.    .    .    else
.    .    .    .    Print 'A'
.    .    New Row

#cplusplus   #gamedesign   #gameprogramming   #java   #minecraft   #programming  
Digital and Interactive Games 2015 – Term 3, Session 17
Today: - Ready Minecraft Plugin for submission

FullGameTutorialFour.java


FullGameTutorialFour.java )

April 2026

S M T W T F S
   12 34
5 678910 11
12 131415161718
19 202122 23 24 25
26 27282930  

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Apr. 29th, 2026 10:36 am
Powered by Dreamwidth Studios