Proposed interface for isometric engine

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Message
Author
chronoluminaire
Eileen-Class Veteran
Posts: 1153
Joined: Mon Jul 07, 2003 4:57 pm
Completed: Elven Relations, Cloud Fairy, When I Rule The World
Tumblr: alextfish
Skype: alextfish
Location: Cambridge, UK
Contact:

Proposed interface for isometric engine

#1 Post by chronoluminaire »

Hello, all! I've pledged to have an isometric engine contributed to the community by February 25th, as part of the LSF@5 Pledges.

Programming is proceeding apace on it, but I've recently been doing a bit of thinking about what people might actually want from it. Only some of this is programmed, and it's all able to be changed, so what I'm after is comments - from people who can conceive of using an isometric engine - as to whether this would meet your needs.

As per Py'Tom's excellent suggestion, I'm splitting the engine into two parts: a Tile Engine, which does things like display the map and sprites, let the user scroll around, and so on; and a Unit Engine on top of the Tile Engine, which does things like remove sprites when the unit's HP hits zero, make it cost movement points to move units around the map, and so on.

My aims / requirements for the Tile Engine are:
  • It should integrate with Ren'Py, to allow Ren'Py commands or code without having to leave the isometric view.
  • It should be usable for a few different types of game:
    • A variety of types of turn-based combat games. That's what rocket and I are going to be using it for ^.^
    • An RPG-style "map screen", either of a continent or of a village, triggering VN-style segments of Ren'Py when the user guides the character to certain regions, without any attacks or considerations of "movement points".
    • Hopefully, quite a number of other possible isometric games like puzzle games.
  • It will support commands to move sprites around on an isometric landscape. These commands will be usable both by the Game System and by the user, to do things like cutscenes.
  • It'll be fairly object-oriented.
A couple of notable things that I'm not planning to do:
  • I'm making no promises about any form of 3D, either layered or heightmaps. It's a possibility for a Version 2 feature. Current plans are just for a flat isometric plain.
  • I won't be making any provision for real-time (time-sensitive) movement. I might not even code anything explicitly to let multiple units move at once, although that would probably be a straightforward customisation for someone to do if they were interested.
  • Unless I can make use of the PGU level editor and tile editor, there won't be any kind of graphical "level editor" for designing maps, or indeed units. You're going to have to edit the text files.
My aims / requirements for the Unit Engine are:
  • It should let the user store information about units: default values will include Name, HP, and so on, but others can be added too.
  • It will support TBS games using either of the two models that I call MP and AP. (MP means each unit gets one move and one attack per turn, although units may have varying distances they can move, determined by Movement Points. AP means each unit has a number of Action Points, and can spend them doing any combination of attacks, moves, or whatever else is possible.)
  • The user should be able to create a pretty basic TBS combat fairly simply.
  • It should provide some basic form of difficulty scaling, as per Ignosco's request below.
  • I'll be providing some form of AI. But it may not be very good, and may be specific to the MP model. If the user wants better AI, they can provide a function that'll get called when a computer-controlled unit gets a turn.

So, consistent with those requirements, an overview of my planned feature specification for the Tile Engine is as follows:
  • The user will define one or more maps, in a python block in an .rpy file in their game.
  • The map will be displayed and the player can scroll around it.
  • The user can show sprites on the screen, with a sensible zorder default (on top of the map but otherwise ordered by screen y).
And an overview of the feature spec for the Unit Engine:
  • It will offer some default overlay views, such as a minimap, and a view of the current unit's name, HP/MaxHP, and so on. These can be customised, either by a set of flags to turn on/off different lines of the view, or as a custom overlay function (which will just be in the form of a standard config.overlay_functions.append() call).
  • The user can specify units for the player and the enemy.
  • The user can define a list of actions to offer to the player for each unit, apart from moving. (Like "Attack", "Use potion", or whatever.)
  • They can specify custom functions to be called on events like: player selects move mode, player moves a unit to a square, player takes an action, enemy unit takes a hit, player unit takes a hit. These can be used, for example, to trigger events when the player moves to a particular region of the map. I'll supply some examples.
  • It'll provide functions to move units around the map, which will be thin wrappers around the corresponding sprite movement functions in the Tile Engine. The user can script cutscenes by calling these functions in sequence from within their Ren'Py code.
  • The user can get a "map screen mode" by just giving the player one unit, with no attacks, and setting movement cost to zero. This would be used in conjunction with a function triggered on the player moving a unit.
The details of each of these are the area most subject to change. Currently, the plan is:
Maps are defined as a two-dimensional array (well, an array of arrays), each element being a struct object with user-settable fields. I include an example file that shows how I'm currently defining the map and the units. Note that the types of terrain are defined beforehand, and then copied for each square of the map.
The Tile Engine will be created from the map. It will provide a number of useful fields, like these:

Code: Select all

python:
  e = TileEngine(map, tileheight, tilewidth)
  e.tileheight, e.tileheight # the full width and height of one tile, in pixels, as supplied
  e.screenheight, e.screenwidth # pixel width and height of the viewport, in pixels
  e.gxmax, e.gymax # size of the map in tiles
  e.Cursor.pos # the coordinates of the square the user's cursor is on
  # e.view.gx, e.view.gy # offset of the map - not so easy to get
Sprites (the images for units etc) will be shown with some kind of call like

Code: Select all

spriteObj = e.showSprite(spritename, gridx, gridy)
The spritename is the name of a Ren'Py image, because this wraps around renpy.show(), doing things like converting the grid coordinates into screen coordinates and providing an appropriate z-order. The returned spriteObj has fields spriteObj.imagename, spriteobj.pos and spriteobj.tag: assigning to any of these will reshow the sprite, moving or changing it.

The Unit Engine also provides some useful fields:

Code: Select all

g.SelectedUnit # the unit that the user has selected to view details of or to issue commands to
g.Mode # Will be equal to one of the constants g.NOSELECTION, g.UNITSELECTED, g.MOVEMODE, g.ACTMODE, g.ENDOFTURN, g.VICTORY, g.DEFEAT, or a custom user mode
g.Callbacks.ModeChange, g.Callbacks.UnitMoves, g.Callbacks.UnitActs # functions that you can assign to; if not at their default value of None, will get called every time the appropriate action happens
Units are defined as an object, like this:

Code: Select all

  Comtron1 = Unit(
    Name = "Comtron 3VT 1",
    Sprite = "lightbot",      # tag for images
    MaxHP = 50,
    MaxMP = 10,   # or MaxAP
    DirectionFacing = DIR_NW, # I provide these eight constants as well as DIR_NEUTRAL
    Pos = (8, 8),         # Define initial position here or later
    CanMove = True,           # These two fields will be filled in automatically if not specified
    CanAct = True,            # After this point you can add any game-specific fields, for example:
    Weapons = [ RIFLE ],
    SelectedWeapon = RIFLE,
    Controller = AYAKA,
    Weight = LIGHT,           
    VisibleByAllies = [ ],
    VisibleByEnemies = [ ]
    )
Units have methods: MoveToSquare(pos, follow=True, spendMP=True) which will find a path for the unit from its current position to pos and move it, updating .Pos and .DirectionFacing, following with the screen unless follow=False, and spending MP/AP according to the map's defined costs unless spendMP=False.

Regions that trigger events can be implemented in ways like this:

Code: Select all

python:
 g.Callbacks.UnitMoves = checkregions
 
label checkregions:
 # the full doc will clarify that the details are passed in Selected.Unit, g.CallbackData.
 if abs(g.SelectedUnit.X - Witch.X) < 2 and abs(gSelectedUnit.Y - Witch.Y) < 2:
  e "She smells terrible..."
 if gSelectedUnit.X in range(10,20) and g.SelectedUnit.Y > 30:
  call SeeValleyForFirstTime
 return
Specifying overlays will be global variables, something like:

Code: Select all

g.Config.ShowMinimapOverlay = False
g.Config.ShowUnitOverlay = True
g.Config.UnitOverlay.ShowUnitMP = False
g.Config.UnitOverlay.ShowUnitWeapons = False
# ...etc
Scripting cutscenes would look something like this:

Code: Select all

# Inside user Ren'Py code
label event_triggered: # this label might be called from an if block inside your checkregions label
 $ g.CentreViewOn((15,8))
 $ Witch.MoveToSquare((15,5))
 witch "So, you've come to see me! I knew you would, you know."
 play sound cackle
 $ Player.MoveToSquare((15,4))
 $ Player.DirectionFacing = DIR_N
 # and so on
I'm going to go ahead with this even if nobody comments, because I need the engine for my TBT ren'ai game. But if you can see yourself using this, then comment, especially if there's something that you'd want that isn't provided by the above, or you're unclear on something :)
Attachments
maps.rpy
(5.09 KiB) Downloaded 162 times
Last edited by chronoluminaire on Mon Feb 18, 2008 1:33 pm, edited 3 times in total.
I released 3 VNs, many moons ago: Elven Relations (IntRenAiMo 2007), When I Rule The World (NaNoRenO 2005), and Cloud Fairy (the Cute Light & Fluffy Project, 2009).
More recently I designed the board game Steam Works (published in 2015), available from a local gaming store near you!

Ignosco
Veteran
Posts: 273
Joined: Mon Dec 25, 2006 10:48 am
Contact:

Re: Proposed interface for isometric engine

#2 Post by Ignosco »

This is a suggestion more from a gameplay perspective: It would be good to have an easy way of implementing difficulty levels (probably scaling HP for one side up or down would be simplest).
Image

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Proposed interface for isometric engine

#3 Post by PyTom »

As a suggestion, you may want to check out PGU:

http://www.imitationpickles.org/pgu/wiki/index

It actually includes an isometric tile engine, along with an editor for maps. I would suggest separating out the tile engine from the game logic... as the game logic will probably be fairly complicated and game-specific, while a decent tile engine could be used for a variety of games.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

chronoluminaire
Eileen-Class Veteran
Posts: 1153
Joined: Mon Jul 07, 2003 4:57 pm
Completed: Elven Relations, Cloud Fairy, When I Rule The World
Tumblr: alextfish
Skype: alextfish
Location: Cambridge, UK
Contact:

Re: Proposed interface for isometric engine

#4 Post by chronoluminaire »

PyTom wrote:As a suggestion, you may want to check out PGU:

http://www.imitationpickles.org/pgu/wiki/index

It actually includes an isometric tile engine, along with an editor for maps.
Hmm. Thanks very much for the link.

That looks... so incredibly potentially useful, and yet... so cryptic and obscure. It looks like it would do several things I've already written, and several more that I'm otherwise going to have to write. But... Maybe it's because I'm basically a Ren'Py programmer, not a Python programmer. But the documentation is awful (I'll never say anything bad about the Ren'Py doc again, having seen this), and... I work on Windows, which means I don't seem to even have a Python executable anywhere. (In the renpy-6.5.0 directory there's python.dll, and under lib/linux-x86 there's python.real, and a shell script called python in the lib directory. Cygwin tries to run the python script and says it can't get anywhere.)

I might try downloading a stand-alone Python install and see if I can make any sense of it, though, because it'd certainly be good if I could. Thanks.
I would suggest separating out the tile engine from the game logic... as the game logic will probably be fairly complicated and game-specific, while a decent tile engine could be used for a variety of games.
Now that is a superb idea. In fact, it's such a fundamental principle that I'm a bit ashamed I didn't take it into account a lot earlier. I'll rework the spec above with that in mind.
I released 3 VNs, many moons ago: Elven Relations (IntRenAiMo 2007), When I Rule The World (NaNoRenO 2005), and Cloud Fairy (the Cute Light & Fluffy Project, 2009).
More recently I designed the board game Steam Works (published in 2015), available from a local gaming store near you!

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Proposed interface for isometric engine

#5 Post by PyTom »

You'll want to grab python2.5 from http://www.python.org and the latest pygame (1.7.1?) from http://www.pygame.org/
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

chronoluminaire
Eileen-Class Veteran
Posts: 1153
Joined: Mon Jul 07, 2003 4:57 pm
Completed: Elven Relations, Cloud Fairy, When I Rule The World
Tumblr: alextfish
Skype: alextfish
Location: Cambridge, UK
Contact:

Re: Proposed interface for isometric engine

#6 Post by chronoluminaire »

Okay, I've rewritten the spec in the first post. Thanks for the comments so far; any more are welcome.

Also, I tried out the PGU.

The tile editor is pretty good, but basically just equivalent to a simple art package, and the GIMP is better (and many people have their own equivalent favourite). Also, it stores all the tiles as chunks of one image, rather than as separate images which is a more Ren'Py way of doing things.

The level editor is also pretty good. I might try to find a way to integrate with that, although it obviously reads its tile images in the format that the tile editor produces them. It seems a bit arbitrary letting each level have precisely three layers - tiles (foreground), background and codes (triggers for enemies etc) - but it's fair enough. It saves them out as .TGA files, which is a bit arbitrary, but I'm sure I could make my code read them. It wouldn't be trivial to integrate with this, but it could be worth the effort.

The isometric engine itself... doesn't really do anything that my home-grown one doesn't. It might have been helpful if I'd found it before I started (like, for example, if I'd bothered to look for Pygame isometric engines at all). It has a big comment at the top saying "Note -- this engine is not finished, any may not work for your particular needs. If you are able to update it, help would be greatly appreciated!"

That, combined with the fact that it expects everything in PGU format, and displays everything in a Pygame way rather than a Ren'Py way, leaves me inclined to not bother trying to use the engine, because I'm wanting to produce something that integrates properly with Ren'Py, and I think that'll be less effort to (continue to) write my own than to try to understand what this (completely undocumented) PGU one does.

But many thanks for the very interesting link, PyTom; and like I say, I'll see if I can take advantage of their level editor.
I released 3 VNs, many moons ago: Elven Relations (IntRenAiMo 2007), When I Rule The World (NaNoRenO 2005), and Cloud Fairy (the Cute Light & Fluffy Project, 2009).
More recently I designed the board game Steam Works (published in 2015), available from a local gaming store near you!

Ivlivs
Veteran
Posts: 267
Joined: Sun Feb 25, 2007 1:00 pm
Contact:

Re: Proposed interface for isometric engine

#7 Post by Ivlivs »

Would a regular square-grid version of this be possible?
Jitteh Dawn --- A VN by Ivlivs

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

Re: Proposed interface for isometric engine

#8 Post by DaFool »

An RPG-style "map screen", either of a continent or of a village, triggering VN-style segments of Ren'Py when the user guides the character to certain regions, without any attacks or considerations of "movement points".
I'm just started keeping tabs on developments in this thread, since I really need a gameplay engine for my next all-ages title. (All-ages titles tend not to be 'high literature', since the writer avoids complicated conflicts, emotions, and situations) Thus the need for light-hearted gameplay-oriented fun with lots of exploration

At first I've been thinking about using the Phoenix Wright engine, but it's hard to capture the charm of its gameplay without your game being a clone of Phoenix Wright, which is a no-no.

RPG battles are also not too appropriate due to their violent nature. But should I ever want to make a clone of Piece of Wonder in the future, then hey!

So yeah, I wonder how this will turn out ^_^. I'm not really good at programming this kind of stuff, but I'm behind you all the way!

chronoluminaire
Eileen-Class Veteran
Posts: 1153
Joined: Mon Jul 07, 2003 4:57 pm
Completed: Elven Relations, Cloud Fairy, When I Rule The World
Tumblr: alextfish
Skype: alextfish
Location: Cambridge, UK
Contact:

Re: Proposed interface for isometric engine

#9 Post by chronoluminaire »

Thanks for the encouragement, DaFool!
Ivlivs wrote:Would a regular square-grid version of this be possible?
That's an intriguing suggestion. It ought to be possible, yes. If I keep my design modular enough, then a square-grid version ought to be able to make use of the map and tile infrastructure I create without needing to be forced into an isometric view.

I'll try to keep this usecase in mind, since I guess Ren'Py doesn't really have an engine for a square-grid tile-based map interface either. No promises, but it ought to be a usecase I can allow pretty easily.
I released 3 VNs, many moons ago: Elven Relations (IntRenAiMo 2007), When I Rule The World (NaNoRenO 2005), and Cloud Fairy (the Cute Light & Fluffy Project, 2009).
More recently I designed the board game Steam Works (published in 2015), available from a local gaming store near you!

blakjak
Veteran
Posts: 224
Joined: Fri Dec 21, 2007 2:36 pm
Location: France
Contact:

Re: Proposed interface for isometric engine

#10 Post by blakjak »

I'm sorry I've got no interesting comments at this stage, but I think that implementing an isometric engine with renpy is an awesome idea.

chronoluminaire
Eileen-Class Veteran
Posts: 1153
Joined: Mon Jul 07, 2003 4:57 pm
Completed: Elven Relations, Cloud Fairy, When I Rule The World
Tumblr: alextfish
Skype: alextfish
Location: Cambridge, UK
Contact:

Re: Proposed interface for isometric engine

#11 Post by chronoluminaire »

This is just an update to let people know the state of this project. When the engines are fully ready to be released, I'll make a separate post, but I'm not quite in that state yet.

The Tile Engine is basically complete. Apart from the massive performance problems, everything else is pretty much ready, I think. I've put the full documentation and a pretty basic tutorial on the Ren'Py wiki.

The Unit Engine is nearly ready. You can create units, move them around (it'll calculate which squares are reachable and how many MP it'll take to move to them), and order them to take other actions like attacks. It won't let you try to move them if they're out of MP, or try to take an action if they've already acted this turn (in the MP model). It'll let you end turns, restoring the MP and actions at the start of each turn. It'll automatically end in defeat when the last friendly unit is destroyed, and you can specify whether you want it to automatically end in victory when the last enemy unit is destroyed.
I've taken the approach that every game's desired actions will be different, so I'm just providing some functions that can be easily plugged together to do common things like shooting at other units. The incomplete Unit Engine tutorial doesn't yet have anything in it about the action system, because I'm still finalising quite which functions I'll make available there.

I've still got a few things on my To Do list for the Unit Engine; I fear it's pretty unlikely I'm actually going to hit the target release date of the 25th February (tomorrow), but I'll be pretty close. If Py'Tom and I are able to get the performance issue fixed, then it's quite likely the engines will be released (including sample tiles and a few different sets of example code) before the end of the month and the start of NaNoRenO.

On the other hand, if the performance issue continues to be intractable, then the release may have to wait until it's fixed.
I released 3 VNs, many moons ago: Elven Relations (IntRenAiMo 2007), When I Rule The World (NaNoRenO 2005), and Cloud Fairy (the Cute Light & Fluffy Project, 2009).
More recently I designed the board game Steam Works (published in 2015), available from a local gaming store near you!

rocket
Veteran
Posts: 373
Joined: Tue Jul 10, 2007 2:54 am
Projects: Starlight Ep0, Ep1
Location: San Fransisco
Contact:

Re: Proposed interface for isometric engine

#12 Post by rocket »

chronoluminaire wrote: I've still got a few things on my To Do list for the Unit Engine; I fear it's pretty unlikely I'm actually going to hit the target release date of the 25th February (tomorrow), but I'll be pretty close. If Py'Tom and I are able to get the performance issue fixed, then it's quite likely the engines will be released (including sample tiles and a few different sets of example code) before the end of the month and the start of NaNoRenO.
Oh.. goody goody! (^_^) Here's to love in war!

Guest

Re: Proposed interface for isometric engine

#13 Post by Guest »

Just posting to say that this'll be a godsend for what I've been trying to do--thanks in advance a whole bunch for all your hard work!

chronoluminaire
Eileen-Class Veteran
Posts: 1153
Joined: Mon Jul 07, 2003 4:57 pm
Completed: Elven Relations, Cloud Fairy, When I Rule The World
Tumblr: alextfish
Skype: alextfish
Location: Cambridge, UK
Contact:

Re: Proposed interface for isometric engine

#14 Post by chronoluminaire »

Guest wrote:Just posting to say that this'll be a godsend for what I've been trying to do--thanks in advance a whole bunch for all your hard work!
Thank you so much for the encouragement! That really does make a difference to me. Particularly as I'm hitting difficulties with performance, it's so encouraging to know that someone else out there besides me is interested in using this :)

I'm hoping to make a preliminary release tomorrow. Until then, you could get a head start by checking out the Tile Engine Tutorial and Unit Engine Tutorial pages I've been putting on the wiki. They're somewhat patchy at the moment, but hopefully they'll give you a feel for what you'll be able to do, and help you start thinking in the right directions :)
I released 3 VNs, many moons ago: Elven Relations (IntRenAiMo 2007), When I Rule The World (NaNoRenO 2005), and Cloud Fairy (the Cute Light & Fluffy Project, 2009).
More recently I designed the board game Steam Works (published in 2015), available from a local gaming store near you!

Ivlivs
Veteran
Posts: 267
Joined: Sun Feb 25, 2007 1:00 pm
Contact:

Re: Proposed interface for isometric engine

#15 Post by Ivlivs »

Please, continue work on this project. I could use this...
Jitteh Dawn --- A VN by Ivlivs

Post Reply

Who is online

Users browsing this forum: 3N16M4, Ocelot