MikeHart
Administrator
- Joined
- Jun 19, 2017
- Messages
- 3,597
Hi folks,
like I have stated in my recent devlog, my son and I want to develop a game together. We settled on a 2D mix of action platformer/RPG/adventure thingy. You have to go on quests, inside and outside. You can travel to other continents, develop your character and so on. The usuable stuff.
We both like pixel art very much, so he will create stuff for it in this style. There is tons of work for us both in the next coming months but with the right tools it can be done. So far he is using Pyxel Edit, which we can only recommend if you want to create pixel art. Great software, damn cheap.
But the rest of tools (map/dialog/character editors, etc.), I will develop my self to have full control over it.
So what have I done coding wise at the moment for it?
A map class which loads the current map file format and renders the tiles.
With a free tilesheet from OpenGameArt I was able to render it quickly in a mojo2 powered canvas:
To load the tilesheet, I thought that this method would make a great addition to mojo2.image:
Btw. its already in our official github repository. I just need to add the docs for it.
That is all for now.
like I have stated in my recent devlog, my son and I want to develop a game together. We settled on a 2D mix of action platformer/RPG/adventure thingy. You have to go on quests, inside and outside. You can travel to other continents, develop your character and so on. The usuable stuff.
We both like pixel art very much, so he will create stuff for it in this style. There is tons of work for us both in the next coming months but with the right tools it can be done. So far he is using Pyxel Edit, which we can only recommend if you want to create pixel art. Great software, damn cheap.
But the rest of tools (map/dialog/character editors, etc.), I will develop my self to have full control over it.
So what have I done coding wise at the moment for it?
A map class which loads the current map file format and renders the tiles.
Cerberus:
Class cMap
Field tiles:Image[]
Field w:Int = 0
Field h:Int = 0
Field tw:Int = 0
Field th:Int = 0
Field m:Int[]
'---------------------------------------------------------------
Method New(path:String)
Local mf:String = LoadString(path+".txt")
Local l:String[] = mf.Split("~n")
Local mi:Int = 0
For Local i:Int = 0 To l.Length()-1
If l[i].Trim().Length()<1 Then Continue
Local s1:= l[i].Split(" ")
If s1.Length()=2
Select s1[0]
Case "tileswide"
w = Int(s1[1])
Case "tileshigh"
h = Int(s1[1])
m = New Int[w*h]
Case "tilewidth"
tw = Int(s1[1])
Case "tileheight"
th = Int(s1[1])
Case "layer"
If Int(s1[1]) = 0
For Local tr:Int = 1 To h
Local trs:String = l[i+tr].Trim()
Local tiles := trs.Split(",")
For Local ti:Int = 1 To w
m[mi] = Int(tiles[ti-1].Trim())
mi += 1
Next
Next
Endif
End
Endif
Next
'Print (w+":"+h+":"+tw+":"+th+" "+ m.Length()+"<>"+tiles.Length())
tiles = Image.LoadFrames(path+".png", tw, th, False, 0.0, 0.0, 0)
End
'---------------------------------------------------------------
Method Render:Void(c:Canvas, xp:Int, yp:Int, factor:Int = 1)
Local i:Int = 0
For Local y:Int = 1 To h
For Local x:Int = 1 To w
c.DrawImage(tiles[m[i]], xp+Int((x-1)*tw)*factor,yp+Int((y-1)*th)*factor, 0, factor, factor)
i+= 1
Next
Next
End
End
With a free tilesheet from OpenGameArt I was able to render it quickly in a mojo2 powered canvas:
To load the tilesheet, I thought that this method would make a great addition to mojo2.image:
Cerberus:
Function LoadFrames:Image[]( path:String,cellWidth:Int,cellHeight:Int,padded:Bool=False,xhandle:Float=.5,yhandle:Float=.5,flags:Int=Image.Filter|Image.Mipmap,shader:Shader=Null )
flags&=_flagsMask
Local material:=.Material.Load( path,flags|Texture.ClampST,shader )
If Not material
DebugLog ("Error - Unable to load image frames: " + path)
Return []
Endif
Local x:=0,width:=cellWidth
If padded x+=1;width-=2
Local tx:Int = material.Width/cellWidth
Local ty:Int = material.Height/cellHeight
Local frames := New Image[tx*ty]
Local i:Int = 0
For Local yi:Int = 0 To ty-1
For Local xi:Int = 0 To tx-1
frames[i]=New Image( material,xi*cellWidth+x,yi*cellHeight,width,cellHeight,xhandle,yhandle )
i += 1
Next
Next
Return frames
End
Btw. its already in our official github repository. I just need to add the docs for it.
That is all for now.
Last edited: