Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

Python/Pygame 2D Isometric Tile Map Editor

Started by AdamShultz Nov 9, 2011 at 9:27 PM 0 replies 2.7k views
Original Post
AdamShultz
AdamShultz
I'm still very new to programming. In fact, the only language I know to any respectable extent is Python, along with the pygame libraries.

With that said, I've been developing this map editor for the last month or so, and I just started re-writing it to conform to the Model-View-Controller (MVC) architecture. This is mainly for two reasons:

A) It will be extremely easy to pickle and unpickle maps this way.
B) It will be extremely simple to implement multiplayer support for maps this way.

To my understanding, in MVC there are three base classes used; Model, View, and Controller, which are all attributes of a class Game (or Program, the lowest level object in an application).

Basically, I create a Model as an attribute to Game, which stores all data and values related to the map.

Then, I create a View as an attribute to Game which has a reference to the Model object, and is supposed to reference resources for the Model's attributes as well as handle rendering and camera and everything else related to what you see.

Finally, I have the Controller as an attribute to Game which has a reference to both the Model object and the View object. This handles user I/O and changes values in both the Model and the View when necessary.

The thing is, I am stumped with how I am supposed to assign things like images to game objects, which are inherently stored in the Model. I can't pickle images, and I can't send them through a network connection as attributes to objects. I can write a function that just blits the appropriate image to the screen and never assigns the image to an object, but that becomes extremely slow and inefficient as the cache dictionary grows with image references. Should I make an Image class and have an Image object take in a GameObject to determine what image (and any changes to the image along with the image's position) the Image object will use for blit and draw calls in View? Or is there a better way to go about doing this?

Any hints or tips are greatly appreciated. Thanks

-Adam

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.