Hello I'm looking for an easy tool to make a tilemap editor with
I just discovered AHK's gui module and I have no idea what it's capable of
I would require either:
the ability to cut up an image and paste the pieces into a large bitmap
or render many small cropped images at once
Thank you
Make a map editor for simple 2D games
- MasterFocus
- Posts: 146
- Joined: 01 Oct 2013, 09:47
- Location: Rio de Janeiro - RJ - Brasil
- Contact:
Re: Make a map editor for simple 2D games
Welcome, Ledrik!
Glad you're here with us sharing your passion for AHK.
You could very well be able to do such application with AHK, definitely.
However, I might as well be direct and point you to Tiled: http://www.mapeditor.org/
As much as the community enjoys creating and even porting things into AHK, I don't think it's always wise to reinvent the wheel.
Glad you're here with us sharing your passion for AHK.
You could very well be able to do such application with AHK, definitely.
However, I might as well be direct and point you to Tiled: http://www.mapeditor.org/
As much as the community enjoys creating and even porting things into AHK, I don't think it's always wise to reinvent the wheel.
Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.
Need help? Please post on the forum before sending me a PM.
Re: Make a map editor for simple 2D games
I just want to try, maybe I'll give up and use something else later but it seems like a good idea for now
I found the docs for Pic but it didn't say anything about cropping or pasting in new pixels
I found the docs for Pic but it didn't say anything about cropping or pasting in new pixels
-
- Posts: 3
- Joined: 16 Nov 2015, 06:48
Re: Make a map editor for simple 2D games
Hello Buddy! Do you even tried tool called: "game maker"? Try Game maker 7, this is the best version in my opinion. I've done a lot of games on it, when i was just a kid.
Good Luck!
Good Luck!
Look at my website and get facetime for android http://facetimeforandroidapk.com/ here.
Re: Make a map editor for simple 2D games
Here's a base for a 2d tilemap script.
Has the basic functionality required and the rendering is quite ezpz, just screenshot and paste into paint
You can use ahk to take a 'snapshot' from the gui and then save it as a file but, most options require a huge wall of text or externals/additional libs so you can add those if you so desire.
Anyway, drop the sprites/tiles you want in the same folder as the script, it'll load them into gui 1 and when you click on a tile in gui 1 it'll add it to gui 2.
To get rid of a tile, just drag it outside of the gui and it'll "disappear".
Has the basic functionality required and the rendering is quite ezpz, just screenshot and paste into paint
You can use ahk to take a 'snapshot' from the gui and then save it as a file but, most options require a huge wall of text or externals/additional libs so you can add those if you so desire.
Code: Select all
tile_w := 48, tile_h := 48
temp_x := 0, temp_y := 0
loop, Files, %a_scriptDir%\*.*
{
if (instr("jpg,png,bmp",a_loopfileext)) {
c++
picList .= a_loopfilename ";"
}
}
stringsplit,picControl,picList,`;
grid_dim := ceil(sqrt(c)), c := 0
loop % grid_dim {
loop % grid_dim {
c++
gui 1: add,picture,x%temp_x% y%temp_y% w%tile_w% h-1 gPicClick vpicControl%c%, % picControl%c%
temp_x += tile_w
}
temp_y += tile_h, temp_x := 0
}
gui_w := tile_w*grid_dim*3, gui_h := tile_h*grid_dim*2
Gui 2: Show, w%gui_w% h%gui_h%, GridMap
gui_w := tile_w*ceil(sqrt(c)), gui_h := tile_h*ceil(sqrt(c))
Gui 1: Show, w%gui_w% h%gui_h%, Sprites
return
PicClick:
gui 1: submit,nohide
gui2c++
gridPicControl%gui2c% := %a_guicontrol%
gui 2: add,picture,x0 y0 w%tile_w% h-1 +wantreturn vgridPicControl%gui2c% gMoveMe, % %a_guicontrol%
return
MoveMe:
while (getKeyState("LButton","P")) {
mousegetpos,mx,my
mx -= (tile_w/2), my -= (tile_h/2)*2
if (mx != px ||my != py) {
guicontrol,move,%a_guicontrol%, x%mx% y%my%
px := mx, py := my
}
}
drop_x := round(px/tile_w)*tile_w
drop_y := round(py/tile_h)*tile_h
guicontrol,move,%a_guicontrol%, x%drop_x% y%drop_y%
return
rshift::
GuiClose:
ExitApp
To get rid of a tile, just drag it outside of the gui and it'll "disappear".
- FanaticGuru
- Posts: 1906
- Joined: 30 Sep 2013, 22:25
Re: Make a map editor for simple 2D games
Nice job John!
FG
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: Make a map editor for simple 2D games
Thanks John, it was really nice of you to do that and it's a neat little program, but I need the ability to cut up a tilesheet into individual tiles or just use one small piece of a tilesheet at a time
Re: Make a map editor for simple 2D games
Code: Select all
;~ #include, Gdip.ahk
src_tilesheet := "PathAndObjects.png"
tile_dim := 32
editor_w := tile_dim*10, editor_h := tile_dim*4
tile_arr := {}
gdip := Gdip_Startup()
bmp := Gdip_CreateBitmapFromFile(src_tilesheet)
bmp_w := Gdip_GetImageWidth(bmp)
bmp_h := Gdip_GetImageHeight(bmp)
tileCount_x := bmp_w/tile_dim
tileCount_y := bmp_h/tile_dim
loop % tileCount_y {
y_index := a_index
loop % tileCount_x {
c++
temp_x := (a_index-1)*tile_dim, temp_y := (y_index-1)*tile_dim
temp_control := "pic" c
gui 1: add,picture,x%temp_x% y%temp_y% w%tile_dim% h-1 hwnd%temp_control% 0xE v%temp_control% gPicClick,
tileBmp := Gdip_CloneBitmapArea(bmp, (a_index-1)*tile_dim, (y_index-1)*tile_dim, tile_dim, tile_dim)
tile_arr[temp_control] := Gdip_CreateHBITMAPFromBitmap(tileBmp)
SetImage(%temp_control%, tile_arr[temp_control])
Gdip_DisposeImage(tileBmp)
}
}
temp_x += tile_dim, temp_y += tile_dim
gui 1: show, w%temp_x% h%temp_y%
Gui 2: Show, w%editor_w% h%editor_h%, GridMap
return
PicClick:
gui2c++
temp_control := "pic_2_" gui2c
gui 2: add,picture,x0 y0 w%tile_dim% h-1 hwnd%temp_control% 0xE v%temp_control% gMoveMe,
SetImage(%temp_control%, tile_arr[a_guicontrol])
return
MoveMe:
while (getKeyState("LButton","P")) {
mousegetpos,mx,my
mx -= (tile_dim/2), my -= (tile_dim/2)*2
if (mx != px ||my != py) {
guicontrol,move,%a_guicontrol%, x%mx% y%my%
px := mx, py := my
}
}
drop_x := round(px/tile_dim)*tile_dim
drop_y := round(py/tile_dim)*tile_dim
guicontrol,move,%a_guicontrol%, x%drop_x% y%drop_y%
return
guiclose:
guiescape:
rshift::
for k in tile_arr {
DeleteObject(tile_arr[k])
}
Gdip_DisposeImage(bmp)
Gdip_ShutDown(gdip)
exitapp
You'll need gdip.ahk but, i'm sure you'll manage.
Re: Make a map editor for simple 2D games
Is there any possible way in the wildest of imaginings of doing it without gdip or dll calls?
Re: Make a map editor for simple 2D games
Not that I know of with a GUI. But by all means, you could do it with an image editor like GIMP or Paint.NET and automating that tool to process cutting an image for you.
Re: Make a map editor for simple 2D games
Hmm, I suppose that's one option
Who is online
Users browsing this forum: mikeyww and 352 guests