Welcome, Guest. Please login or register.

Pages: [1]
Print
Author Topic: events on the map  (Read 7152 times)
tZee
Community member

Posts: 190


View Profile Email
« on: June 12, 2009, 09:07:12 AM »

Hello,

Yesterday in IRC there was some brainstorming going on about how to best implement teleportation between maps. According to mvBarracuda teleporting into houses is a bit more complicated and should be worried about at a later point.

I don't agree on this. If you start implementing things partly and worry about the rest later you will end up rewriting a lot of code. So here is what I thought of:

Teleportation tiles are the same as doors or traps or a bed etc. They're objects in the world with which you can interact. So why not give them the possibility to add event listeners for actions like: WalkOver, Use etc. The agents are the ones who trigger them. Like for teleportation, the Agent notifies every tile/object he walks over, that he is doing so. If there are any events associated with that they will trigger. Here the hero would be teleported to the new map.

The use action needs some more thought, though. For most objects it would be fine to walk up to it to use it, but still the hero wouldn't be standing on the tile. So the event would have to be triggered e.g. by the context menu. Then again there needs to be something like a range check for these types of events. Imagine there is a darts game. You wouldn't want to walk up to it to throw the arrow. Cheesy
Logged

Dave Matney
Community member

Posts: 230


29640090 naveofhearts@hotmail.com naveking matneyx
View Profile Email
« Reply #1 on: June 12, 2009, 04:28:34 PM »

To respond to the conversation in IRC, how to deal with the teleport tiles (clicked on and immediately moved to the new map, or walked over), I think it should be an intentional thing, eg. you click on the tile and it "activates" then, once your sprite is there, THEN you teleport.  If you don't click on the tile and your sprite walks over it, then no harm, no teleport.
Logged
maximinus
Community member

Posts: 694



View Profile Email
« Reply #2 on: June 12, 2009, 04:59:38 PM »

To respond, unlike barra I think that teleporting into houses is very VERY similar to transporting to another level on the code side.

Also, since there is bound to be a lot of computation when we move from level to level (saving the data, getting the NPC moves, loading the level and parsing the XML etc...) you can't expect it to be instant; therefore I would also think it best to have to select the option of moving rather than the chance of it happening by accident.
Logged

Science is open-source religion
mvBarracuda
Admin
Community member

Posts: 1308



View Profile Email
« Reply #3 on: June 12, 2009, 07:18:04 PM »

Hey, that's unfair! I think I actually did not say that loading the interieur of a building map is much different to loading another map. It would be different if we would go for the Fallout / Arcanum approach that buildings would be actually part of the map where the building resides but as we decided to go down the Planescape Torment route and move them to separate maps, their handling will be pretty close to loading another map.
Logged
zenbitz
Community member

Posts: 1164



View Profile
« Reply #4 on: June 12, 2009, 11:19:29 PM »

Quote
I don't agree on this. If you start implementing things partly and worry about the rest later you will end up rewriting a lot of code. So here is what I thought of:

It took me a long time to learn this, but rewriting code IS programming.
Logged

We are not denying them an ending...
We are denying them a DISNEY ending - Icelus
maximinus
Community member

Posts: 694



View Profile Email
« Reply #5 on: June 13, 2009, 02:25:46 AM »

Quote
I don't agree on this. If you start implementing things partly and worry about the rest later you will end up rewriting a lot of code. So here is what I thought of:

It took me a long time to learn this, but rewriting code IS programming.

Definitely. And you learn more about the engine or library you are using at well. Shuffling round code also lets you realise what works as an architecture as well.
Logged

Science is open-source religion
meggie
Community member

Posts: 30

Python programming looking for some C++ experience

un1meg
View Profile
« Reply #6 on: June 13, 2009, 02:45:06 AM »

And speaking of which, you can now teleport to another map with a press of the 'c' key. You have to change the settings.xml file (which isn't under revision control?) in addition to applying the patch. You must add the map2 line below. I don't think it matters where you add it. This is what that area of mine looks like:

Code:
<MapFile> maps/map.xml </MapFile>
<map2> maps/map2.xml </map2>
<Font> fonts/amanata.ttf </Font>

I can switch back and forth between the two maps multiple times. The PC is re-created anew each time a map is loaded, we can probably wait to fix that until we actually implement how the PC will move from map to map. I actually have no idea how the listeners for this will work.

I have an alternate Hero class that has an extra state (_STATE_TELE), and an InstanceChangeListener. This class knows (with a slight addition to engine.py) when it's time to change maps, but we would need some way for the Hero to convey to world.py 1) it's time to change! and 2) what tile the Hero should be on in the new map, and what the new map should be. I don't know how to do this, or if giving Hero this extra listener is the best way to do it. I'm throwing it out there because I have it (partly) implemented.

And we may want to scrap the TeleTile class entirely. Dunno. It's there to be flexible (and modular! yay! -_-).

Anyway, please see if this works for the rest of you.

* map_change.patch (15.33 KB - downloaded 260 times.)
Logged

-Meggie
maximinus
Community member

Posts: 694



View Profile Email
« Reply #7 on: June 13, 2009, 05:29:18 AM »

Patched and commited as revision 128. Good work!
Logged

Science is open-source religion
maximinus
Community member

Posts: 694



View Profile Email
« Reply #8 on: June 13, 2009, 05:55:32 AM »

Hi meggie, I added a door to the shanty hut so I'll build a hut interior tonight to test with.

You should probably add the map name from the map_objects.xml file instead of changing the settings file.

Finally, I know it's a very minor nit-pick but can you use spaces and not tabs in the XML files as well?
Logged

Science is open-source religion
maximinus
Community member

Posts: 694



View Profile Email
« Reply #9 on: June 13, 2009, 08:55:18 AM »

If you look at my code I've implemented move between maps as right-clicking objects.

I left in the c key so you can go back!
Logged

Science is open-source religion
tZee
Community member

Posts: 190


View Profile Email
« Reply #10 on: June 13, 2009, 08:40:52 PM »

Quote
I don't agree on this. If you start implementing things partly and worry about the rest later you will end up rewriting a lot of code. So here is what I thought of:

It took me a long time to learn this, but rewriting code IS programming.

That is merely coding and not the optimum. If you want to program you should sit down for a moment, before you start coding, and think about what you want to achieve and how it could be reused. Programming is about abstraction and reusability. Design towards interfaces.

Definitely. And you learn more about the engine or library you are using at well. Shuffling round code also lets you realise what works as an architecture as well.

That is true, if you don´t know the engine you are working with and how it is supposed to used, then you can´t help but rewrite code and learn from it. But this teleporting thing is not engine specific and I think it should be designed in a flexible way.
I´m just online for a brief moment. On monday I will have a look at the code and see how you solved it.  Smiley
Logged

maximinus
Community member

Posts: 694



View Profile Email
« Reply #11 on: June 13, 2009, 11:50:41 PM »

Quote
I don't agree on this. If you start implementing things partly and worry about the rest later you will end up rewriting a lot of code. So here is what I thought of:

It took me a long time to learn this, but rewriting code IS programming.

That is merely coding and not the optimum. If you want to program you should sit down for a moment, before you start coding, and think about what you want to achieve and how it could be reused. Programming is about abstraction and reusability. Design towards interfaces.

I think I use this mantra: get it working, then get it right. So our first job was to work out how to do it; only then can we make the code look good. That experimentation insists that you start with writing code.
Logged

Science is open-source religion
tZee
Community member

Posts: 190


View Profile Email
« Reply #12 on: June 15, 2009, 02:33:38 PM »

I think my last posting was too pretentious, sorry for that. I think I assessed the situation of the project/the goal of the hola demo wrongly. Smiley
When I'm home tonight I'll have a proper look around in the other threads and the wiki.
Logged

maximinus
Community member

Posts: 694



View Profile Email
« Reply #13 on: June 15, 2009, 02:59:55 PM »

I think my last posting was too pretentious, sorry for that.

Probably my answer was as well   Roll Eyes

People program in different ways, and there is no right way. My thoughts are generally "if you don't like the code, then make it better".  Smiley
Logged

Science is open-source religion
Pages: [1]
Print
Jump to: