Perintah Dasar Greenfoot PPT I

Download Report

Transcript Perintah Dasar Greenfoot PPT I

Drs. Sugeng Rianto, M. Sc.
Ubaidillah, S. Si
Greenfoot
Software yang didesain untuk belajar
teknik pemrograman berorientasi Object
 Opensource dan Merupakan aplikasi grafis
dengan bahasa pemrogramman JavaTM
 Mudah digunakan untuk membuat game
atau simulasi grafis 2D

Instalasi

Greenfoot tersedia dalam beberapa
Operating System (OS), salah satunya
Ms. Windows
http://www.greenfoot.org/

Komputer sudah terinstal Java 5 atau >
http://java.sun.com/j2se/
User Interface
Creating a New Scenario

Scenario == “Project”
Creating a New Scenario

Scenario baru dengan Class World dan
Actor Kosong
Using the API

API (Application Programming Interface)
Creating a World
Properti-properti World
getWidth()
 getHeight()
 getObjects()
 getObjectsAt()
 setBackground()
 addObject()
 removeObject()

removeObjects()
 numberOfObjects()
 …etc

Ukuran dan Resolusi World
Background World
Mode background  tiles
Background World
Creating New Actors
First Compiling

Klik tombol Compile
Properti-properti Actor
getX()
 getY()
 getRotation()
 getWorld()
 setLocation(posx,posy)
 setRotation(sudut)
 setImage(GreenfootImage)

Adding Actor to World

Klik kanan atau dengan sambil menekan tombol Shift
Make Actor Move
Run Option
Compile setiap kali selesai mengedit
Random


Set kecepatan yang
berbeda untuk setiap
Buaya
Harus sesuai dengan
nama World yang
digunakan
Keyboard Input
Dengan memodifikasi fungsi
Move(int a):
Keyboard Input
Single Key Input
Klik tombol space sekali
Mouse Input

Mouse Moved
 if(Greenfoot.mouseMoved(this))

Clicked (Single Clicked)
 if(Greenfoot.mouseClicked(this))

Dragged
 if(Greenfoot.mouseDragged(this))

DragEnded
 if(Greenfoot.mouseDragEnded(this))

Pressed
 if(Greenfoot.mousePressed(this))
MouseMoved
mouseMoved(null)  null digunakan
untuk mendeteksi mouse digerakkan
di World
Mouse Dragged
Penambahan variabel
rx dan ry digunakan
agar Object yang
digeser sesuai titik
pertama dari Object
ketika mouse ditekan
mouseDragged()
seringkali dikuti
mouseDraggedEnded()
Mouse Pressed
Diperlukan sedikit penyesuaian,
penambahan variabel pressed
Next Week
Greenfoot Primitive Objects
 String  Scorring
 Image Manipulation
 Intersecting (Tumbukan/Collision)
 Penambahan efek suara
 Exporting Scenario

Contoh Implementasi Lain (Animasi)
Contoh Implementasi Lain (2D VR):
Pustaka

Kölling, Michael and Martin Pain. 2010.
The Greenfoot Programmers' Manual.
University of Kent.