473,289 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

Re: Relationship between GUI and logic?

On May 23, 1:37 pm, John Salerno <johnj...@gmailNOSPAM.comwrote:
Basically, the question is this: can you write the logic behind a
program (whether it be a game, an email client, a text editor, etc.)
without having any idea of how you will implement the GUI?
Hey John,

Are you familiar with the Model-View-Controller pattern? It
specifically addresses this issue, and is very common in game
development.

In your example of a grid-based game like chess, the board & the
pieces would all be defined in the Model. The board may be a 2D array,
so to move a piece, the piece only has to know how to address
locations within the array, or even better, only has to know how to
tell the board where it's moving to, so the pieces don't have to know
how the board is implemented.

The View interprets & displays the Model. You could represent each
square by a bitmap, draw a 3d object, or use ASCII etc etc.

The Controller maps user input to Model behaviour, so pressing 'up'
while a piece is highlighted may call something like
piece.move_north(), which updates the necessary entities in the Model
to reflect the move. It generally also passes information from the
Model to the View, although it's not uncommon for the View to just
refer to the Model separately.

So you can think of the Model as a simulation of the behaviour you
want, while the View is _a_ representation of that simulation. The
simulation doesn't care if you're displaying it in 2D or 3D, it cares
about pieces and board positions. By separating the Model & the View,
you also allow for multiple representations of the same data, such as
having a 2D overhead map and a 3D visualisation of the same
information.

- alex23
Jun 27 '08 #1
0 599

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Alcyone Oliveira | last post by:
------=_NextPart_000_000D_01C36572.F6480CE0 Content-Type: multipart/alternative; boundary="----=_NextPart_001_000E_01C36572.F6480CE0" ------=_NextPart_001_000E_01C36572.F6480CE0 Content-Type:...
0
by: Mike Sutton | last post by:
Please let me know what you think of this scheme I have come up with (not to imply that noone else has before me) for managing relationships. I have created an entities table with Individual and...
8
by: Andante.in.Blue | last post by:
Hello, I have just inherited a legacy Access 97 database. While going through it, I noticed something strange... its Relationships window (the one accessed by Tools --> Relationships) is almost...
2
by: Rararachel | last post by:
Hi All, (Have posted this elsewhere, so apologies to anyone who's seen this behemoth before!) I have a simple, but surprisingly complicated database requirement in that the database requires...
5
by: BrianDP | last post by:
This is a strange one-- I have an Access 2K database with a split front end/back end. There are two tables in the back end - RFile and RLine. There is a one to many relationship from...
1
by: BuckBaxter | last post by:
Recently had trouble creating a one-to-many relationship between Customer table and Order table. After drag & dropping the field CustomerNo (key) in Customer table to CustomerNo (foreign) in Order...
4
by: Ray | last post by:
in UML? I just found that UML is actually very class-based. It's difficult to depict the relationship between a constructor function, its prototype property, and objects that are created using that...
0
by: Marc 'BlackJack' Rintsch | last post by:
On Fri, 23 May 2008 07:14:08 -0400, inhahe wrote: The logic part has the rules how you may move the pieces. The GUI shouldn't have to know how a knight, bishop, or queen can move or what...
4
by: Phil Stanton | last post by:
Having spent ages sorting out the layout of my relationship window with about 60 tables and getting it all tidy and with enough of the tables visible to show the PK an FK relaionshipsOn a subseqent...
6
by: NicoleCartrette | last post by:
Going back to school is easier said than done.. This was posted to an older thread earlier but I don't think it got any attention. Your help is appreciated Professor requires we create a...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.