MGDW4 Online Camp #3b - State Management
Upcoming SlideShare
Loading in...5
×
 

MGDW4 Online Camp #3b - State Management

on

  • 751 views

 

Statistics

Views

Total Views
751
Views on SlideShare
751
Embed Views
0

Actions

Likes
0
Downloads
82
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • http://games.wiki.staffs.ac.uk/Modules/Module_Specific_Pages/2A_Game_Design_Assignments_Wikis/2A2B_2010/Survival_Horror%2F%2FPredator_Horror_Game/Screen_Flow

MGDW4 Online Camp #3b - State Management MGDW4 Online Camp #3b - State Management Presentation Transcript

  • Mobile Game Developer War 4: Online CampMGDW4 Online Camp 3.2 State Management
  • Mobile Game Developer War 4: Online Camp Apa itu state?• Dalam game kita perlu menyimpan berbagai informasi: – Level dan status pemain Informasi-informasi tersebut – Stage yang sudah dibuka disebut juga dengan game state. – Highscore, achievements – Berbagai quest atau misi yang dijalankan pemain
  • Mobile Game Developer War 4: Online Camp State ManagementSuatu mekanisme untuk menyimpan danmengolah informasi state dalam sebuah game.
  • Mobile Game Developer War 4: Online Camp Contoh penggunaan• Screen transition – Menentukan layar apa yang kita tampilkan pada suatu saat – Misalnya: Main menu, option menu, in game, pause menu, dll
  • Mobile Game Developer War 4: Online Camp Contoh penggunaan• RPG Game State – Menentukan pemain sedang menjalani event/quest/misi apa – State tersebut akan mempengaruhi respon dari game – Contohnya: NPC X akan bergabung dengan party jika pemain sudah mengalahkan monster Y Di game Suikoden II, di akhir permainan akan ada event khusus jika kita berhasil mengumpulkan 108 karakter.
  • Mobile Game Developer War 4: Online CampKonsep di balik State Management• State management disimpan dalam bentuk graph atau flowchart – Sebuah state digambarkan dengan suatu node – Setiap state akan memiliki satu atau lebih transisi (baik dari atau menuju state tsb) – Setiap transisi akan dipengaruhi oleh suatu trigger atau nilai tertentu
  • Mobile Game Developer War 4: Online CampContoh Kasus: Screen Flow
  • Mobile Game Developer War 4: Online Camp Implementasi State Manager• Kita perlu menyimpan state dalam suatu variabel, misalnya integer untuk kode screen saat ini• Untuk mengecek state kita dapat menggunakan if atau switch-case• Pengecekan perlu dilakukan di setiap bagian yang terpengaruh• Misalnya untuk screen, akan mempengaruhi: – Input Untuk bagian koding materi ini bisa – Draw melanjutkan dari project yang sebelumnya, hanya draw dan – Update getInput yang banyak berubah :D
  • Mobile Game Developer War 4: Online Camp //fungsi draw //deklarasi variabel penting private void draw(){ int screenState; switch (screenState) { case SCREEN_MAIN_MENU: final int SCREEN_MAIN_MENU = 0; //... final int SCREEN_OPTION = 1; break; final int SCREEN_LEVEL_SELECTION= 2; case SCREEN_OPTION: final int SCREEN_TUTORIAL = 3; //... final int SCREEN_IN_GAME = 4; break; final int SCREEN_PAUSE = 5; case SCREEN_LEVEL_SELECTION: //... final int SCREEN_RESULT = 6; break; final int SCREEN_EXIT = 7; case SCREEN_IN_GAME: //... Kode untuk setiap state bisa kita simpan break; case SCREEN_TUTORIAL: dalam variabel dengan nama yang jelas //... break; case SCREEN_PAUSE:private void init(){ //... gameover = false; break; screenState = SCREEN_MAIN_MENU; case SCREEN_RESULT:} //... break; case SCREEN_EXIT:State awal perlu kita tentukan //... break; default: Implementasi state management break; } dengan switch-case -> }
  • Mobile Game Developer War 4: Online Camp Isi fungsi draw//...(lihat di slide sebelumnya)case SCREEN_MAIN_MENU: g.setColor(0x000000); g.drawString("Main Menu Screen", 10, 0, Graphics.TOP | Graphics.LEFT); g.drawString("^ Go to Option", 10, 50, Graphics.TOP | Graphics.LEFT); g.drawString("> Play Game", 10, 100, Graphics.TOP | Graphics.LEFT); g.drawString("< Exit", 10, 150, Graphics.TOP | Graphics.LEFT); break;case SCREEN_OPTION: g.setColor(0xff0000); g.drawString("Option Screen", 10, 0, Graphics.TOP | Graphics.LEFT); g.drawString("^ Back to main menu", 10, 50, Graphics.TOP | Graphics.LEFT); g.drawString(“> Play game", 10, 100, Graphics.TOP | Graphics.LEFT); break;case SCREEN_LEVEL_SELECTION: g.setColor(0x00ff00); g.drawString("Level Selection Screen", 10, 0, Graphics.TOP | Graphics.LEFT); g.drawString("^ Back to main menu", 10, 50, Graphics.TOP | Graphics.LEFT); break;case SCREEN_IN_GAME: g.setColor(0x0000ff); g.drawString("Game Screen", 10, 0, Graphics.TOP | Graphics.LEFT); break;//...(lihat di slide sebelumnya)
  • Mobile Game Developer War 4: Online Camp Isi fungsi draw//...(lihat di slide sebelumnya)case SCREEN_MAIN_MENU: g.setColor(0x000000); g.drawString("Main Menu Screen", 10, 0, Graphics.TOP | Graphics.LEFT); g.drawString("^ Go to Option", 10, 50, Graphics.TOP | Graphics.LEFT); g.drawString("> Play Game", 10, 100, Graphics.TOP | Graphics.LEFT); g.drawString("< Exit", 10, 150, Graphics.TOP | Graphics.LEFT); break;case SCREEN_OPTION: g.setColor(0xff0000); g.drawString("Option Screen", 10, 0, Graphics.TOP | Graphics.LEFT); g.drawString("^ Back to main menu", 10, 50, Graphics.TOP | Graphics.LEFT); g.drawString(“> Play game", 10, 100, Graphics.TOP | Graphics.LEFT); break;case SCREEN_LEVEL_SELECTION: g.setColor(0x00ff00); g.drawString("Level Selection Screen", 10, 0, Graphics.TOP | Graphics.LEFT); g.drawString("^ Back to main menu", 10, 50, Graphics.TOP | Graphics.LEFT); break;case SCREEN_IN_GAME: g.setColor(0x0000ff); g.drawString("Game Screen", 10, 0, Graphics.TOP | Graphics.LEFT); break;//...(lihat di slide sebelumnya)
  • Mobile Game Developer War 4: Online Camp Implementasi transisi screenprivate void getInput(){ 1 int keystate = getKeyStates(); Bagian yang berwarna merah adalah switch (screenState) { case SCREEN_MAIN_MENU: implementasi transisi antar state if (keystate == LEFT_PRESSED){ if(!lefthold){ screenState = SCREEN_EXIT; lefthold=true; case SCREEN_OPTION: } if(keystate == UP_PRESSED){ 2 }else lefthold=false; if(!uphold){ if(keystate == UP_PRESSED){ screenState = SCREEN_MAIN_MENU; if(!uphold){ uphold=true; screenState = SCREEN_OPTION; } uphold=true; }else uphold=false; } break; }else uphold=false; case SCREEN_LEVEL_SELECTION: if (keystate == RIGHT_PRESSED){ if(keystate == UP_PRESSED){ if(!righthold){ if(!uphold){ screenState = SCREEN_LEVEL_SELECTION; screenState = SCREEN_MAIN_MENU; righthold=true; uphold=true; } } }else righthold=false; }else uphold=false; break; break; //...silahkan lengkapi untuk setiap screen default: break; } }
  • Mobile Game Developer War 4: Online Camp Quest: Coba kalian lengkapi sampai semua flow menu pada flowchart diimplementasiHasil sejauh ini:
  • Mobile Game Developer War 4: Online Camp Cara menyelesaikan Quest1. Kirim source code MainCanvas.java ke email: quest@agateacademy.com2. Gunakan subject “Quest Online Camp 03b – State Management”
  • Mobile Game Developer War 4: Online Camp• Untuk menyelesaikan materi, kunjungi http://bit.ly/KsDbj1• Untuk pertanyaan atau diskusi, bisa dilakukan via forum: http://bit.ly/mgdw4forum