• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

DevLog An untitled platformer/RPG

Status
Not open for further replies.

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. :cool:

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:

1549566640500.png


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:
Status
Not open for further replies.
Back
Top Bottom