Results 1 to 10 of 10

Thread: Writting map editor from scratch tutorial (With Allegro)

  1. #1

    Writting map editor from scratch tutorial (With Allegro)

    Do you know of any tutorials that teaches you how to write map editor from scratch using Allegro.pas/Allegro library? Might be C Allegro as I have no troubles converting C code into pascal (headers are another story though).

    The reason of this is that I want to use my own map editor with custom, binary data format for my next game (after Super Heli Land) that saves to custom binary data format, so maps would be fast (XML are text files and as such they take bit longer to process than binary data) and I won't have troubles with loading/saving them properly as it'll be my own data format.

    Plus, I would get valuable experience.

  2. #2
    First of all graphic library which you use doesn't have much inpact on making game map editor woth exceptions of 2D and 3D capabilities.
    Also it laregly depends on what kinda game are you trying to make.

    But in short if you know how to make game it shouldn't be hard to know how to make editor. If we are talking about 2D game you only need to make yourself and aplication which provide you with the ability to chose and place certain parts of the mape (usually sprites).

    Not so long ago I was helping another member with making of editor for his own planned game. We haven't finished it which might also be partially my fault. I actually lead him to wrong path on faulty asumption that something can't be done using the graphic engine he was using (I asumed that the graphic engine doesn't have any optimization) so we wasted several weaks on implementing custom optimization which only lead him to confusion. I hope I won't make same mistake again.

    Any whay you can find some more infor on this here (all of our mishaps): http://www.pascalgamedevelopment.com...er-Game-Editor

  3. #3
    Well with this being tilemap editor (think more RPG Maker than, say, The Games Factory) I would have most difficulties with snapping tiles to grid and showing grid cursor.

    How do I determine which "tile" user clicked as in snapping mouse to grid of certain size?
    How do I make showing "tile cursor" (small square of size according to tile's size) in proper place instead of always under mouse?

  4. #4
    Quote Originally Posted by Darkhog View Post
    How do I determine which "tile" user clicked as in snapping mouse to grid of certain size?
    Easy!
    GridXPosition := Mouse.X div GridCellWidth;
    And if your map is bigger than what you can render on the screen you have to take into acount your viewing position. So if your viewing position on X axis is at coordinates 145 the forumla would look like this:
    GridXPosition := (Mouse.X + ViewpoirtX) div GridCellWidth;

    Quote Originally Posted by Darkhog View Post
    How do I make showing "tile cursor" (small square of size according to tile's size) in proper place instead of always under mouse?
    Once you have grid position you can simply multiply it by grid size like this.
    SelectorSprite.X := GridXPosition * GridCellWidth;
    And if your map is larger than the screen
    SelectorSprite.X := (GridXPosition * GridCellWidth) - ViewportX;

  5. #5
    And if map's viewport is moved away from 0,0 (top-left corner) and occupy only part of screen (after all tile palette should go somewhere), equation would be:
    GridXPosition := OffsetX + ((Mouse.X + ViewpoirtX) div GridCellWidth);

    am I correct?

  6. #6
    No, you don't need 2 offset variables, ViewPointX already does that. If you wanted to also draw a tool panel (instead of using IDE components) on the left side, and always draw the entire map more to right, then you would use OffsetX. But then it would be
    GridXPosition := ((Mouse.X + ViewPointX - ToolPanelWidth) div GridCellWidth);
    Last edited by User137; 13-06-2013 at 04:30 PM.

  7. #7
    Well, allegro.pas don't mix well with Lazarus' forms and allegro gui library looks terrible (just look at ASEPRITE for example).

  8. #8
    Quote Originally Posted by Darkhog View Post
    Well, allegro.pas don't mix well with Lazarus' forms
    None of the game graphical engines doesn't mix wel with either VCL or LCL. The main reason for this is the technology that is used for each learegly differs from others.
    Most game graphical libraries use either DirectX or OpenGL as their main technology.
    VCL and LCL use default system GUI which is quite slow in comparison to DirectX or OpenGL. Also the biggest problem of default OS GUI is that it laregly depends on system messages which can also be quite slow. That is why it is much better to create your own internal game messaging system rather than using OS messaging system.

  9. #9
    I'm experimenting with forms based ui along with opengl scene rendering, so far so good

  10. #10
    Quote Originally Posted by laggyluk View Post
    I'm experimenting with forms based ui along with opengl scene rendering, so far so good
    No problems with that, as long as you don't draw WinAPI controls, such as buttons on top of rendering scene.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Comodo SSL