Friday 14 December 2018

Google + Content reposting - Apr 25 2015 - 2


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  





No comments:

Post a Comment