Reply
 
Thread Tools Display Modes   
 
Model - View - Controller Pattern untuk Game
 
Old 06/02/2008, 08:47 Reply With Quote   #1
kunilkuda
Junior Member
 
No Avatar
 
Join Date: Feb 2008
Location: KL
Posts: 2
kunilkuda is on a distinguished road
Send a message via Yahoo to kunilkuda Send a message via Skype™ to kunilkuda kunilkuda is offline
Model - View - Controller Pattern untuk Game

Gw pengin memisahkan antara rendering logic dan game logic. Ada yang tahu gimana cara misahinnya dalam Model-View-Controller responsibility ?

Berikut adalah beberapa pemikiran gw ttg task dan kategorinya:
1) Init graphic/screen : View
2) Rendering sprite : View
3) Detecting which sprite that user choose : <don't know> (asumsi bahwa ada beberapa sprite yang bisa dipilih oleh user dalam game)
4) Init timer : Controller
5) Update game model : Controller
6) Detecting user input : Controller
7) Play audio : Model
8 ) Collition detection : <don't know>
9) Sprite attributes (image, color, position, speed, etc) : Model

Ada yang bisa kasih ide ?

Thanks
-kunil
   
 
 
Old 06/02/2008, 09:00 Reply With Quote   #2
pe-e-be
Alien dari lab GAIB
 
pe-e-be's Avatar
 
Join Date: Jul 2005
Location: lab gaib itb, bandung
Posts: 1,587
pe-e-be is on a distinguished road
Send a message via Yahoo to pe-e-be pe-e-be is offline
eh, ada kunil.. ini kunil BHTV?
__________________
liku-liku hidup.
game, dapur dan perspektif.
hire me here
   
 
 
Old 06/02/2008, 09:07 Reply With Quote   #3
Ultraman_Bastard
Ultraman Bekas
 
Ultraman_Bastard's Avatar
 
Join Date: Jul 2006
Location: ndenpasar..
Posts: 2,860
Ultraman_Bastard is on a distinguished road
Send a message via ICQ to Ultraman_Bastard Send a message via AIM to Ultraman_Bastard Send a message via MSN to Ultraman_Bastard Send a message via Yahoo to Ultraman_Bastard Send a message via Skype™ to Ultraman_Bastard Ultraman_Bastard is offline
BHTV?? *berpikir keras*
__________________
1 - 2 - 3 - 4 - 5 - 6
   
 
 
Old 06/02/2008, 09:11 Reply With Quote   #4
bhimz
Anak Game Indonesia™
 
bhimz's Avatar
 
Join Date: Nov 2006
Location: Jakarta
Posts: 492
bhimz is on a distinguished road
Send a message via Yahoo to bhimz bhimz is offline
Actually, several frameworks/language/tools sepertinya sudah menerapkan ini, tinggal gmn cara makenya (what game type/language are we talking about btw?). Mungkin ada baiknya kamu menggali sedikit dokumentasinya.
In response ke pembagian MVC berdasarkan pemikiran u, sepertinya gw lebih setuju kalau dibuat seperti ini:
View: Interface building, Sprite factory, Sound handler, collision detection
Controller: page handler (chaining antar interface), user input handler, game ticker & logic
Model: game attributes, char attributes, collision detection (bisa juga disini, kalau mau dianggep sebagai attribut char), user interface model (model dasar yg dipake buat ngebangun user interface di view)

As for detecting sprite yg digunakan, relevansi itu seharusnya ada di level user interface juga.
__________________
Dare yourself to Dream.. Be a part of the ImajiNATION.

My old gamebook project:
http://geocities.com/bhimz2001/
My totally unrelated blog :
http://bhimz.blogspot.com/
   
 
 
Old 06/02/2008, 09:12 Reply With Quote   #5
pe-e-be
Alien dari lab GAIB
 
pe-e-be's Avatar
 
Join Date: Jul 2005
Location: lab gaib itb, bandung
Posts: 1,587
pe-e-be is on a distinguished road
Send a message via Yahoo to pe-e-be pe-e-be is offline
hmm, tergantung sih mau game yang seperti apa dulu dan seberapa jauh generalisasi yang diharapkan dari MVC...

klo game yang umum, mungkin begini :
- Model : Level, Scenegraph, Assets, Game AI (mungkin juga bisa dipindah ke controller klo cukup sederhana), Configuration
- View : Renderer, Input Manager, Audio Player, Network Engine
- Controller : Application, Game Screen, Collision, AI (Pathfinding/Rule-based) Engine
__________________
liku-liku hidup.
game, dapur dan perspektif.
hire me here
   
 
 
Old 06/02/2008, 09:49 Reply With Quote   #6
HeapCleaner
Twisted minded comicer!
 
HeapCleaner's Avatar
 
Join Date: Oct 2004
Location: IP pandu kiwi PVJ BEC
Posts: 1,883
HeapCleaner is on a distinguished road
Send a message via Yahoo to HeapCleaner HeapCleaner is offline
BHTV = Bandung High Tech Valley
__________________
my artworks
   
 
 
Old 06/02/2008, 10:01 Reply With Quote   #7
Ultraman_Bastard
Ultraman Bekas
 
Ultraman_Bastard's Avatar
 
Join Date: Jul 2006
Location: ndenpasar..
Posts: 2,860
Ultraman_Bastard is on a distinguished road
Send a message via ICQ to Ultraman_Bastard Send a message via AIM to Ultraman_Bastard Send a message via MSN to Ultraman_Bastard Send a message via Yahoo to Ultraman_Bastard Send a message via Skype™ to Ultraman_Bastard Ultraman_Bastard is offline
weh.. keren.. ada ya kayak gitu di bandung.. *kapan ada di bali ya??
__________________
1 - 2 - 3 - 4 - 5 - 6
   
 
 
Old 06/02/2008, 10:30 Reply With Quote   #8
ace
BANNED FOREVER!!!
 
ace's Avatar
 
Join Date: Jul 2005
Posts: 2,151
ace is on a distinguished road
ace is offline
don't judge the book by it's cover
   
 
 
Old 06/02/2008, 10:36 Reply With Quote   #9
Kiki
Kiki++
 
Kiki's Avatar
 
Join Date: Sep 2005
Posts: 801
Kiki is on a distinguished road
Kiki is offline
Menurut saya, kalau mau konsisten dengan paradigma MVC, sprite seharusnya nggak masuk dalam konsiderasi. Sebaiknya dipakai dua buah class : Entity di layer Model dan EntityView di layer View. EntityView harus berhubungan somehow dengan Entity, saya usulkan dengan menggunakan Observer Pattern (EntityView adalah observer dari Entity). Data Dari Entity dan EntityView mungkin diduplikasi, tapi tersinkronisasi oleh mekanisme observer (contoh : Data Rectangle di Entity dan EntityView diduplikasi. akan tetapi ketika data Rectangle di Entity berubah, mungkin karena entity tersebut bergerak, Entity akan menotifikasi perubahan tersebut ke entityview yang akan mengatur data rectanglenya supaya tersinkronisasi dengan rectange milik entity) .

1. Init Graphic/screen : view (obvious)

2. Render Sprite : View -> Ini diganti dengan Render EntityView. tentu saja EntityView "own" sprite supaya bisa menggambar.

3. Detecting which sprite that user choose: ->What about something like this: There's an attribute in Entity that correspond to a "look" in EntityView. Whenever that attribute change, the Entity notifies EntityView thet the attribute changes. In turn, EntityView will change its "look", and as the owner of sprite, will change the sprite to match the "look".

4. Init timer : Controller -> obvious

5. Update game model : Controller ->obvious

6. Detecting user input : Controller -> obvious

7. Play audio : Model :-> why not view ? I do not have a good argument why it should be view, though.

8. Collition detection : -> Ini bisa dilakukan di layer model, contohnya dengan Rectangle yang disebut sebelumnya. Ini adalah salah satu alasan mengapa beberapa data di Model dan View harus di duplikasi dan disinkronisasi.

9. Sprite attributes (image, color, position, speed, etc) : Model -> Make that attribute of Entity. With the Observer mechanism this attribute also available to EntityView, and can be used to render the sprite if necessary.

PS: Actually I do not really care with MVC paradigm
__________________
Wir haben die Kunst, damit wir nicht an der Wahrheit zugrunde gehen.
   
 
 
Old 06/02/2008, 10:57 Reply With Quote   #10
L_O_J
Ulat tak berbulu
 
L_O_J's Avatar
 
Join Date: Dec 2003
Posts: 1,674
L_O_J is on a distinguished road
Send a message via Yahoo to L_O_J L_O_J is offline
@Kiki:
7. Play Audio bisa disamakan dengan render sprite (image), so it's a view, Modelnya ya raw audio data.
8. Collision itu controller kali ya, di Model cuman rectanglenya aja (or pixel data kalo mau pixel perfect collision), sedangkan actual process of detecting it ada di controller.
__________________
"Experience is something that you got when you don't get something that you want" - Randy Pausch ( The Last Lecture )
"The brick wall is there for a reason, to separate those who really want it and the rest" - Randy Pausch ( The Last Lecture )
   
   Reply « Previous Thread| Next Thread »     


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT +7. The time now is 19:50.


skin developed by: uray
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.