Project 2D - Tile-Based Game Engine

Post your working scripts, libraries and tools
User avatar
TheDewd
Posts: 1135
Joined: 19 Dec 2013, 11:16
Location: USA

Project 2D - Tile-Based Game Engine

05 May 2015, 16:08

Image

Introduction
Project 2D is a tile-based 2D game engine created using AutoHotkey. Its purpose is to allow users to create games using only a text editor and basic image editing.

According to Wikipedia:
"A tile-based video game is a type of video or video game where the playing area consists of small rectangular, square, or hexagonal graphic images, referred to as tiles. The complete set of tiles available for use in a playing area is called a tileset. Tiles are laid out adjacent to one another in a grid; usually, some tiles are allowed to overlap, for example, when a tile representing a unit is overlaid onto a tile representing terrain. Tile-based games usually simulate a top-down or "2.5D" view of the playing area, and are almost always two-dimensional."

https://en.wikipedia.org/wiki/Tile-based_video_game
Getting Started
Before you can begin creating your first game, you'll need to download the current release of the Project 2D engine. The download links are available at the end of this post.

After you've downloaded the compressed zip archive, you'll need to extract the files to a directory on your computer. The Windows operating system should be capable of handling files with the zip extension, however you may download a third-party software such as 7-Zip to open the archive.

Project 2D is configured with an initial demonstration game as an example of how to use image and text files to create a multi-room level, and interact with the game environment.


Creating Backgrounds
The background is the image file that will be display behind the player. It's used to create the environment of the level, to create the appearance of a room or objects... The display area of the game is 640x640 pixels, using a 20x20 grid of 32x32 pixel tiles. The background image must match these dimensions to fit accurately in the game window.

A background can be created in any image editor, but I recommend using a tiled map editor when possible. A tiled map editor is like a stamping tool, allowing background images to be created and edited with ease. Visit one of the following links for more information:
Source: http://www.tilemapeditor.com/

To use a tiled map editor, you must have a tile map image (or collection of images). The tile map used in the demonstration is provided at the end of this post.


ASCII Maps
Project 2D uses text files to store information used for interacting with the current background image. This is where you define the boundaries of the room and location of objects, etc... Each 32x32 pixel tile of your background image can be assigned a numerical value of 0-9 which can be used to trigger an action when the player is occupying the space at that tile's coordinates.

You can create and edit the ASCII map files using a text editor, or you may use the ASCII Map Editor script that is attached at the end of this post.

Note that while the main window uses a 20x20 grid, the ASCII maps use a 22x22 grid to allow the player object to trigger an action while outside of window's viewable area.


Additional Resources
Many websites are devoted to sharing resources to assist you with building assets for your games, or just to provide inspiration. A few examples are listed below:
Special Thanks
A special thank you and show of appreciation to those that have contributed to this project:
Please share any suggestions or ideas for improvement. It's always appreciated!


Screenshots
Title Screen (640 x 640 px) - Click to enlarge
Image

Floor 3 (640 x 640 px) - Click to enlarge
Image

ASCII Map Editor (720x 762px) - Click to enlarge
Image


Downloads
Project 2D
The most recent release of Project 2D
Project2D_rev2.zip (336.67 KB) - March 13, 2017

ASCII Map Editor
Visual editor for creating and editing the ASCII map files
MapEdit_rev2.zip (5.84 KB) - March 13, 2017

Demo Tilemap
Images collected from various sources
Demo_Tilemap.png (7.85 KB) - June 08, 2016

Archive
These files are outdated and kept for archival purposes only. Please refer to the most recent releases for the latest additions and improvements.
Project2D_rev1.zip (92.83 KB) - June 08, 2016
Project_2D_20150507002944.zip (214.81 KB) - May 07, 2015
Project_2D_20150505210148.zip (12.03 KB) - May 05, 2015
MapEdit_rev1.zip (3.29 KB) - June 14, 2016


https://westoncampbell.github.io/Project2D/
Last edited by TheDewd on 16 Mar 2017, 08:59, edited 37 times in total.
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
User avatar
joedf
Posts: 6692
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: Project 2D - Grid-Based Game Engine

05 May 2015, 18:15

Awesome, i gotta try this :D
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 3.00 GHz, 16GB DDR4 3200 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
User avatar
TheDewd
Posts: 1135
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Project 2D - Grid-Based Game Engine

05 May 2015, 18:22

joedf wrote:Awesome, i gotta try this :D
At the moment, the current preview just demonstrates collision with objects such as walls, and picking up items. The HP potion will refill your health bar.
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
User avatar
TheDewd
Posts: 1135
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Project 2D - Tile-Based Game Engine

06 May 2015, 20:16

I updated the first post with better information about the project. I also added an updated version of the script.
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
User avatar
Iomega0318
Posts: 83
Joined: 06 Apr 2015, 14:56
Facebook: jonimpson
Google: jonimpson
GitHub: Iomega0318
Location: Wolfforth, TX
Contact:

Re: Project 2D - Tile-Based Game Engine

07 May 2015, 14:37

That's actually really amazing and I might just play around with this :)
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

Re: Project 2D - Tile-Based Game Engine

08 May 2015, 02:21

Awesome!
Everything is possible!
User avatar
Hajin
Posts: 32
Joined: 13 May 2016, 09:16

Re: Project 2D - Tile-Based Game Engine

15 May 2016, 07:01

Useful, my script of collision had improvements, somehow.
____________________________________________________________________________________

Can anyone help me here?
https://autohotkey.com/boards/viewtopic ... 18&t=17798

My Scripts In This Forum:
____________________________________________________________________________________
SirRFI
Posts: 404
Joined: 25 Nov 2015, 16:52

Re: Project 2D - Tile-Based Game Engine

15 May 2016, 11:31

Haha, I was thinking if such a thing would be possible doing in AHK many times, and I thought of the same methods You used as well.

Code: Select all

If (PlayerX = 320) AND (PlayerY = 224)
{
 Return
}
These are used for collision? Maybe You could make an array with unaccessable spots and loop through them, rather than manually flood these ifs?
Use

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.
User avatar
Gio
Posts: 504
Joined: 30 Sep 2013, 10:54
Location: Brazil

Re: Project 2D - Tile-Based Game Engine

16 May 2016, 17:27

Very interesting, thanks for sharing!
"What is suitable automation? Whatever saves your day for the greater matters."
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
User avatar
TheDewd
Posts: 1135
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Project 2D - Tile-Based Game Engine

08 Jun 2016, 16:21

I updated the first post with the download link to the newest version... Added support for ASCII text maps for setting your level's boundaries, etc...

Please test this new version and let me know what you think about it! :-)
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
rommmcek
Posts: 391
Joined: 15 Aug 2014, 15:18

Re: Project 2D - Tile-Based Game Engine

10 Jun 2016, 09:24

Hi!

You are making really tremendously amazing stuff!
However gaming is not my passion! Nevertheless, your first platform inspired me to make an ancient logical game in such environment.
It supports playing against computer (default) as well as against an other player.
F3: restart
F5: hint, multiple presses give randomly alternative hints if availabile
F8: force computer to play
F9 - F12: shortcuts to oblivion (F9 for smallest.. F12 for biggest)
Arrows: for navigation
Enter: next player
Esc: Exit
Rules: In order to survive the player must drink at least one vial (blue an green are potions). The one who drinks red vial (poison) loses. Other rules should be self-explanatory due to new environment!

Thanks!
Attachments
Project_2D.1.zip
(590.81 KiB) Downloaded 222 times
User avatar
TheDewd
Posts: 1135
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Project 2D - Tile-Based Game Engine

10 Jun 2016, 10:30

rommmcek wrote:...your first platform inspired me to make an ancient logical game in such environment.
It's really interesting having the player control's movements automated when operated by the "computer". I like your ideas and implementation for your game. Very good! Thank you for sharing! :)
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
User avatar
SnowFlake
Posts: 368
Joined: 28 Apr 2015, 05:41
Google: floowsnaake
GitHub: floowsnaake
Contact:

Re: Project 2D - Tile-Based Game Engine

10 Jun 2016, 14:10

Nice work :D

Also maybe add a Map Editor or something? on top of my head idea editor
Image
Map Editor thingy.zip
Map Idea editor thingy
(1.73 KiB) Downloaded 206 times
:yawn:
User avatar
joedf
Posts: 6692
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: Project 2D - Tile-Based Game Engine

11 Jun 2016, 14:43

Map editor: Cool haha :+1:
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 3.00 GHz, 16GB DDR4 3200 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
User avatar
SnowFlake
Posts: 368
Joined: 28 Apr 2015, 05:41
Google: floowsnaake
GitHub: floowsnaake
Contact:

Re: Project 2D - Tile-Based Game Engine

11 Jun 2016, 16:09

Im thinking about reading the .map/text file and then over laying it on top of the map but i don't know a way of making 1 number in each Box
Image

but then again im not that good At AHK and there are probably a tons of better ways of doing a map editor

Code: Select all

#SingleInstance Force
SetWorkingDir %A_ScriptDir%
GridControl = 0
MarkerControl = 0

Global GridControl
Global MarkerControl

XXMoveScale = 216
YYMoveScale = 64

XXMarkCoord = 1
YYMarkCoord = 1

FileRead,mm1,\resources\maps/bg_0001.map
Gui, Margin, 32, 32

Gui Add, text, x216 y18 w100 h30 vMarkCoord,Marker At: 0
Gui Add, text, x326 y18 w400 h30 vMaptext,
Gui Add, Picture, x216 y64 w680 h680 vMap,%SelectedFile%
Gui Add, text, x216 y64 w680 h680 +BackgroundTrans vmm cBlue,%mm1%
Gui Add, Picture, x216 y64 w683 h683 0x5000000E 0x6 Border +BackgroundTrans,
Gui Add, Picture, x216 y64 w680 h680 0x5000000E 0x6 Border +BackgroundTrans,grid - Copy.png
Gui Add, Picture, x216 y64 w32 h32 0x5000000E 0x6 Border +BackgroundTrans hide vGrinder,marker.png

Gui Add, Button, x34 y80 w75 h23 gLM, Load Map
Gui Add, Button, x34 y110 w95 h23 gGrid vgridder, Hide Grid
Gui Add, Button, x34 y140 w110 h32 gMarker vplacermark, Hide Place Marker
Gui Add, Button, x34 y190 w110 h32 gMarker v3placermark, Show Items
Gui Show, w906 h750, Project 2D Map Editor

Gui, Font, cblue s12
Return

GuiEscape:
GuiClose:
    ExitApp

Right::
XXMoveScale+=32
GuiControl, Move, marker.png,X%XXMoveScale%
XXMarkCoord++
GuiControl,,MarkCoord,Marker At: %XXMarkCoord%/%YYMarkCoord% XY:%YYMoveScale%/%XXMoveScale%
return

Left::
XXMoveScale-=32
GuiControl, Move, marker.png,X%XXMoveScale%
XXMarkCoord--
GuiControl,,MarkCoord,Marker At: %XXMarkCoord%/%YYMarkCoord% XY:%YYMoveScale%/%XXMoveScale%
return

Up::
YYMoveScale-=32
GuiControl, Move, marker.png,Y%YYMoveScale%
YYMarkCoord--
GuiControl,,MarkCoord,Marker At: %XXMarkCoord%/%YYMarkCoord% XY:%YYMoveScale%/%XXMoveScale%
return

Down::
YYMoveScale+=32
GuiControl, Move, marker.png,Y%YYMoveScale%
YYMarkCoord++
GuiControl,,MarkCoord,Marker At: %XXMarkCoord%/%YYMarkCoord% XY:%YYMoveScale%/%XXMoveScale%
return

Marker:
MarkerControl++

IF (MarkerControl = 1)
{
GuiControl,hide,marker.png
GuiControl,,placermark, Show Place Marker
}
else
{	
GuiControl,show,marker.png
GuiControl,,placermark, Hide Place Marker
MarkerControl = 0
}
return

Grid:
GridControl++

IF (GridControl = 1)
{
GuiControl,hide,grid - Copy.png
GuiControl,,gridder, Show Grid

}
else
{	
GuiControl,show,grid - Copy.png
GuiControl,,gridder, Hide Grid
GridControl = 0
}
return


LM:
FileSelectFile, SelectedFile, 3,resources\images , Select a Map Laout, Map Lyout (*.png)
if SelectedFile =
    MsgBox, The user didn't select anything.
else

GuiControl,,Maptext,Map Loaded:`n%SelectedFile%
GuiControl,, Map,%SelectedFile%
GuiControl, Font,mm
return
:yawn:
User avatar
joedf
Posts: 6692
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: Project 2D - Tile-Based Game Engine

11 Jun 2016, 17:29

Well a quick and dirty trick would be picture controls with an image of zero or one (with the same size as a square) then overlayed
or better is use a monospaced font and align them accordingly to the grid. :)
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 3.00 GHz, 16GB DDR4 3200 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
User avatar
TheDewd
Posts: 1135
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Project 2D - Tile-Based Game Engine

14 Jun 2016, 15:47

SnowFlake wrote:Im thinking about reading the .map/text file and then over laying it on top of the map but i don't know a way of making 1 number in each Box
SnowFlake/joedf,

Thank you for your ideas! I've created an ASCII Map Editor and updated the first post with the download link.

It's a very quick and dirty version at the moment with lots of repetitive code. I'll try to clean it up for the next release.

Please try the editor and let me know what you think!

ASCII Map Editor
Visual editor for creating and editing the ASCII map files
Image
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
User avatar
joedf
Posts: 6692
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: Project 2D - Tile-Based Game Engine

14 Jun 2016, 16:27

@TheDewd
Very nice work there! :+1:
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 3.00 GHz, 16GB DDR4 3200 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
User avatar
SnowFlake
Posts: 368
Joined: 28 Apr 2015, 05:41
Google: floowsnaake
GitHub: floowsnaake
Contact:

Re: Project 2D - Tile-Based Game Engine

14 Jun 2016, 18:30

wow thats great :D

Idea:
Now we need a second window that show the textures/objects and make it so that you click on a tile and the textures/object shows up there and then its basically done :P

this will make it a lot easier to make maps and also make it easier for newer ppl to make there own games with this engine!

great job keep it up proud of you!
:yawn:

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 23 guests