GLBasic forum

Codesnippets => 2D-snippets => Topic started by: erico on 2014-Nov-19

Title: The Case of Joseph Curwen
Post by: erico on 2014-Nov-19
A quick (8h) implementation of a future game I plan to create, here in a very simple form.
Did it for AI class as an example of rule based system...but adding a pinch of fun.

The code is probably a winner on the awards of the worst-fast-rogue-savage code written ever by a human been but heck, it does resolve the proposal.
That must matter me thinks. ::)

Have fun.

how to play the mess?
.rogue style + action points
.4 turns for player, move with arrows, space trigger and untrigger the gun (6 chamber), triggering cost no ap.
.when triggered, shot with arrow on that direction
.if head shot, kill zombie, otherwise it pushes him back if an empty space
.you must scavenge all tombs (T) and leave map through entrance.
.tomb can replenish 1 health or full ammo.
.2 turns for zombies

F1 change views (standard ascii, array info, gfx)

not quite balenced, but no time to anything, I must finish Msc semester in the usual last time hurry. ;)
The code is on the zip as a TXT, try not to laugh too hard hehe. :booze:
Some game design on the pdf in portuguese br.

more on this latter...


edit: ahhhh such is the power of the powers in GLBASIC! :)
Title: Re: The Case of Joseph Curwen
Post by: erico on 2014-Nov-19
ops...why not add a screen shot? :whip:

botter not for the constant debug info on the right. :whistle:
Title: Re: The Case of Joseph Curwen
Post by: Ian Price on 2014-Nov-19
Looks like the odds are stacked against you in that screenie erico! :P

I'll give this a try later. Cheers :)
Title: Re: The Case of Joseph Curwen
Post by: matchy on 2014-Nov-19
Alrighty!  =D

It's not easy as I was only able to obtain x3 "T"s.   :sick:
Title: Re: The Case of Joseph Curwen
Post by: Ian Price on 2014-Nov-19
I managed 4 or 5 :)

I expected it to be "proper" turn based (more like AquaVenture). Are all Rogue-Likes "move 4 places and then wait for enemies to move"? That threw me at first.
Title: Re: The Case of Joseph Curwen
Post by: MrPlow on 2014-Nov-19
Cool!!
Look forward to this!

Have started on a rogue-like from ages ago but never got round to it.

Looks nice!
Ian, normally enemies move every time player moves but maybe they are 4x slower than the player :)

Title: Re: The Case of Joseph Curwen
Post by: erico on 2014-Nov-19
Quote from: Ian Price on 2014-Nov-19
...
I expected it to be "proper" turn based (more like AquaVenture). Are all Rogue-Likes "move 4 places and then wait for enemies to move"? That threw me at first.

Yep, I guess it is more like an X-Com thing for the player. The zombies though, move like a proper rogue, each one takes a turn then each one takes another turn so to spend 2 action points.

This was all really badly-quickly implemented, I used a lot of SLEEP command, which responds differently per computer.
I´m sure to make it a proper game at some point in january/february. 
Title: Re: The Case of Joseph Curwen
Post by: erico on 2014-Nov-19
Here the source code, add the MEDIA from last download to this and you have it working.

It is really a huge mess of code, but I hope this can help teach people 2 things:
-how not to code a game.
-how GLB can get you there even if a messy code. :P

You can design your own map at the DATA at the end.
Also, the rules that move the zombies are 3 stage based on distance from the player:
-FAR total random movement.
-MID 80% chance of moving towards player, 20% chance of random movement.
-CLOSE move towards player.

It is, of course, a flawed system when you consider a closed space level, like houses and so on. The zombies also see through obstacles.
I can win the game easily on the open level, it is just a matter of crowd control, your 4 steps puts you on a great advantage.
Ya, gather some zombies following you and you create a bubble space between CLOSE and FAR distance, you can exploit this.
Level 2 is harder, specially if the tomb is located on a more closed space, like the top left part. It is still manageable when you know what to expect from the engine.

edit: There is also a dirty trick in the way I edited the font graphics to use it as sprites...
Code (glbasic) Select
// --------------------------------- //
// Project: LD - O Caso de Joseph Curwen
// Start: Monday, November 17, 2014
// IDE Version: 12.243

//--- BOOT
LIMITFPS 60
SETSCREEN 800,600,0
SETCURRENTDIR("Media")
LOADFONT "f1.bmp",1
LOADFONT "f0.bmp",2
SETFONT 1
LOADSOUND "click 01.wav",1,1 ;//energia tumba
LOADSOUND "click 02.wav",2,1 ;//exit fuga
LOADSOUND "click 03.wav",3,1 ;//bullets tumba
LOADSOUND "click 05.wav",5,1 ;//hit zumbi
LOADSOUND "click 06.wav",6,1 ;//tiro
LOADSOUND "click 09.wav",9,2 ;//hit
LOADSOUND "click 10.wav",10,1 ;//exit morte
LOADSOUND "click 11.wav",11,1 ;//hit zumbi head shooooot
LOADSOUND "click 12.wav",12,1 ;//gatilho

//--- VARIABLES
GLOBAL db // debug on off
GLOBAL c // DECLARE X COUNTER VARIABLE
GLOBAL d // DECLARE Y COUNTER VARIABLE
GLOBAL m[] // DECLARE BOARD VARIABLE
DIM m[32][32] // DIMENSION BOARD VARIABLE
GLOBAL t // General timer
GLOBAL tx, ty // localizador geracao de tumbas
GLOBAL px,py,pe,pb // PLAYER x,y,energia,balas
GLOBAL rd // round player/zombie
GLOBAL tr // turn (4 player 2 zumbi)
GLOBAL kc // key control so move com >25
GLOBAL tc // tumba count (10)
GLOBAL zx[],zy[] // xy xumbixs
DIM zx[50]
DIM zy[50]
GLOBAL zc // zombie count max 50
zc=49 // total-1
GLOBAL zdx,zdy // distancia player
GLOBAL zd // dado para movimentacao (0-3)
GLOBAL s // 0 normal 1 shoot
GLOBAL bx,by, bg // bullet x y gasta
GLOBAL h$
GLOBAL map
INPUT h$,10,10
IF h$="0"
map=0
ELSE
map=1
ENDIF
//--- LOAD MAP
IF map=0 THEN RESTORE MAPA1 // load board
IF map=1 THEN RESTORE MAPA2
FOR d=0 TO 31 // generate board data into array
FOR c=0 TO 31
READ m[c][d]
NEXT
NEXT

//--- GERAR TUMBAS
tc=10 // tumba count 10
FOR t=0 TO 9
tx=RND(31) ; ty=RND(31)
IF m[tx][ty]=0
m[tx][ty]=4
ELSE
t=t-1
ENDIF
NEXT

//--- GERAR PLAYER
px=RND(1)+15 // xy player
py=31
pe=5
pb=6


//--- GERAR ZUMBIS
FOR c=0 TO zc
zx[c]=RND(31) // limite no mapa y perto player
zy[c]=RND(24)
IF m[zx[c]][zy[c]]<>0 // verifica bloco livre
c=c-1
ENDIF
IF m[zx[c]][zy[c]]=0 // marca zumbi no mapa
m[zx[c]][zy[c]]=8
ENDIF
NEXT



// MAINLOOP--------------------------[start]
WHILE TRUE
bx=px ; by=py
//--- PLAYER---------------------------------------------------------------------------------------
IF rd=0

//--- movimento
kc=kc+1
IF kc>10 AND tr<5 // checar kc
IF KEY(200)=1 AND s=0
py=py-1
IF py<0 THEN py=0 // out of bound
kc=0 // zera key count timer
tr=tr+1 // +turn
IF m[px][py]=1 OR m[px][py]=8 // limita zumbi e parede
py=py+1
ENDIF
ENDIF
IF KEY(208)=1 AND s=0
py=py+1
IF py>31 THEN py=31 // out of bound
kc=0 // zera key count timer
tr=tr+1 // +turn
IF m[px][py]=1 OR m[px][py]=8 // limita zumbi e parede
py=py-1
ENDIF
ENDIF
IF KEY(205)=1 AND s=0
px=px+1
IF px>31 THEN px=31 // out of bound
kc=0 // zera key count timer
tr=tr+1 // +turn
IF m[px][py]=1 OR m[px][py]=8 // limita zumbi e parede
px=px-1
ENDIF
ENDIF
IF KEY(203)=1 AND s=0
px=px-1
IF px<0 THEN px=0 // out of bound
kc=0 // zera key count timer
tr=tr+1 // +turn
IF m[px][py]=1 OR m[px][py]=8 // limita zumbi e parede
px=px+1
ENDIF
ENDIF
IF KEY(28)=1 AND s=0 // movimento pass
kc=0
tr=tr+1
ENDIF
//--- SHOOT!!!!!!!!!!!!!!
IF KEY(57)=1 AND s=0 AND pb>0 // trigger
kc=0
s=1
bx=px
by=py
PLAYSOUND (12,0,1)
ENDIF
IF s=1 AND kc>10
IF KEY(200)
PLAYSOUND (6,0,1)
pb=pb-1
FOR d=0 TO 32
by=by-1
FOR c=0 TO zc
IF m[bx][by]=1 OR m[bx][by]=3 OR m[bx][by]=4 //ricochete
bg=1
bx=px
by=py
ENDIF
IF bx=zx[c] AND by=zy[c] AND bg=0 //zombie collision hit
m[zx[c]][zy[c]]=0
zy[c]=zy[c]-1
PLAYSOUND (5,0,1)
IF m[zx[c]][zy[c]]<>0 //limite
zy[c]=zy[c]+1
ENDIF
IF RND(4)=0 //head shot
zx[c]=0;zy[c]=0
PLAYSOUND (11,0,1)
ELSE
m[zx[c]][zy[c]]=8 //update map zombie data
ENDIF
bg=1
ENDIF
NEXT
SLEEP 15
NEXT
s=0
kc=0
bg=0
tr=tr+1
ENDIF
IF KEY(208)
PLAYSOUND (6,0,1)
pb=pb-1
FOR d=0 TO 32
by=by+1
FOR c=0 TO zc
IF m[bx][by]=1 OR m[bx][by]=3 OR m[bx][by]=4 //ricochete
bg=1
bx=px
by=py
ENDIF
IF bx=zx[c] AND by=zy[c] AND bg=0 //zombie collision hit
m[zx[c]][zy[c]]=0
zy[c]=zy[c]+1
PLAYSOUND (5,0,1)
IF m[zx[c]][zy[c]]<>0 //limite
zy[c]=zy[c]-1
ENDIF
IF RND(4)=0 //head shot
zx[c]=0;zy[c]=0
PLAYSOUND (11,0,1)
ELSE
m[zx[c]][zy[c]]=8 //update map zombie data
ENDIF
bg=1
ENDIF
NEXT
SLEEP 15
NEXT
s=0
kc=0
bg=0
tr=tr+1
ENDIF
IF KEY(205)
PLAYSOUND (6,0,1)
pb=pb-1
FOR d=0 TO 32
bx=bx+1
FOR c=0 TO zc
IF m[bx][by]=1 OR m[bx][by]=3 OR m[bx][by]=4 //ricochete
bg=1
bx=px
by=py
ENDIF
IF bx=zx[c] AND by=zy[c] AND bg=0 //zombie collision hit
m[zx[c]][zy[c]]=0
zx[c]=zx[c]+1
PLAYSOUND (5,0,1)
IF m[zx[c]][zy[c]]<>0 //limite
zx[c]=zx[c]-1
ENDIF
IF RND(4)=0 //head shot
zx[c]=0;zy[c]=0
PLAYSOUND (11,0,1)
ELSE
m[zx[c]][zy[c]]=8 //update map zombie data
ENDIF
bg=1
ENDIF
NEXT
SLEEP 15
NEXT
s=0
kc=0
bg=0
tr=tr+1
ENDIF
IF KEY(203)
PLAYSOUND (6,0,1)
pb=pb-1
FOR d=0 TO 32
bx=bx-1
FOR c=0 TO zc
IF m[bx][by]=1 OR m[bx][by]=3 OR m[bx][by]=4 //ricochete
bg=1
bx=px
by=py
ENDIF
IF bx=zx[c] AND by=zy[c] AND bg=0 //zombie collision hit
m[zx[c]][zy[c]]=0
zx[c]=zx[c]-1
PLAYSOUND (5,0,1)
IF m[zx[c]][zy[c]]<>0 //limite
zx[c]=zx[c]+1
ENDIF
IF RND(4)=0 //head shot
zx[c]=0;zy[c]=0
PLAYSOUND (11,0,1)
ELSE
m[zx[c]][zy[c]]=8 //update map zombie data
ENDIF
bg=1
ENDIF
NEXT
SLEEP 15
NEXT
s=0
kc=0
bg=0
tr=tr+1
ENDIF
IF KEY(57)=1 // destrigger
kc=0
s=0
PLAYSOUND (12,0,1)
ENDIF
ENDIF
//--- SHOOT!!!!!!!!!!!!!! END
ENDIF

//--- tumba collect
IF m[px][py]=4
IF RND(1)=0 // energy
pe=pe+1
IF pe>5 THEN pe=5
PLAYSOUND (1,0,1)
ELSE
pb=6 // bullets
PLAYSOUND (3,0,1)
ENDIF
m[px][py]=0
tc=tc-1 //tc tumba coletada
ENDIF

//--- FINISH PLAYER ROUND
IF tr=5
tr=0
rd=1
kc=0
ENDIF
IF tr=4
SLEEP 15 //delay falso thinking
tr=5
kc=0
ENDIF

ENDIF
//--- PLAYER END--------------------------------------------------------------------------------

//--- ZUMBI-------------------------------------------------------------------------------------
IF rd=1
tr=tr+1 // avanca turn (max 2)
FOR c=0 TO zc
zdx=zx[c]-px // gera variavel de distancia
zdy=zy[c]-py
IF zdx<0 THEN zdx=zdx*-1 // transforma variavel em positivo
IF zdy<0 THEN zdy=zdy*-1

IF zdx>12 AND zx[c]<>0 AND zy[c]<>0 OR zdy>12 AND zx[c]<>0 AND zy[c]<>0 // FAR distancia mov------------------->
m[zx[c]][zy[c]]=0 // clear map current zombie data
zd=RND(3) //dado
IF zd=0
zx[c]=zx[c]-1
IF m[zx[c]][zy[c]]<>0 //limite
zx[c]=zx[c]+1
ENDIF
ENDIF
IF zd=1
zx[c]=zx[c]+1
IF m[zx[c]][zy[c]]<>0 //limite
zx[c]=zx[c]-1
ENDIF
ENDIF
IF zd=2
zy[c]=zy[c]-1
IF m[zx[c]][zy[c]]<>0 //limite
zy[c]=zy[c]+1
ENDIF
ENDIF
IF zd=3
zy[c]=zy[c]+1
IF m[zx[c]][zy[c]]<>0 //limite
zy[c]=zy[c]-1
ENDIF
ENDIF
ENDIF
IF (zdx>7 AND zdx<13 AND zdy<13 AND zx[c]<>0 AND zy[c]<>0) OR (zdy>7 AND zdy<13 AND zdx<13 AND zx[c]<>0 AND zy[c]<>0) // MID distancia mov------------------->
m[zx[c]][zy[c]]=0 // clear map current zombie data
zd=RND(5) //dado
IF zd<5
zd=RND(1) //redado direcao corte diagonal
IF zx[c]<px AND zd=0
zx[c]=zx[c]+1
IF m[zx[c]][zy[c]]<>0 //limite
zx[c]=zx[c]-1
ENDIF
ENDIF
IF zx[c]>px AND zd=0
zx[c]=zx[c]-1
IF m[zx[c]][zy[c]]<>0 //limite
zx[c]=zx[c]+1
ENDIF
ENDIF

IF zy[c]<py AND zd=1
zy[c]=zy[c]+1
IF m[zx[c]][zy[c]]<>0 //limite
zy[c]=zy[c]-1
ENDIF
ENDIF
IF zy[c]>py AND zd=1
zy[c]=zy[c]-1
IF m[zx[c]][zy[c]]<>0 //limite
zy[c]=zy[c]+1
ENDIF
ENDIF
ENDIF
IF zd>4
zd=RND(3) //RE dado
IF zd=0
zx[c]=zx[c]-1
IF m[zx[c]][zy[c]]<>0 //limite
zx[c]=zx[c]+1
ENDIF
ENDIF
IF zd=1
zx[c]=zx[c]+1
IF m[zx[c]][zy[c]]<>0 //limite
zx[c]=zx[c]-1
ENDIF
ENDIF
IF zd=2
zy[c]=zy[c]-1
IF m[zx[c]][zy[c]]<>0 //limite
zy[c]=zy[c]+1
ENDIF
ENDIF
IF zd=3
zy[c]=zy[c]+1
IF m[zx[c]][zy[c]]<>0 //limite
zy[c]=zy[c]-1
ENDIF
ENDIF
ENDIF
ENDIF
IF zdx<8 AND zdy<8 AND zx[c]<>0 AND zy[c]<>0 // CLOSE distancia mov------------------->
m[zx[c]][zy[c]]=0 // clear map current zombie data
zd=RND(3) //dado
IF zd<6
IF zx[c]<px AND zd<3
zx[c]=zx[c]+1
IF zx[c]=px AND zy[c]=py ;//collision player
pe=pe-1
PLAYSOUND (9,0,1)
zx[c]=zx[c]-1
ENDIF
IF m[zx[c]][zy[c]]<>0 //limite
zx[c]=zx[c]-1
ENDIF
ENDIF
IF zx[c]>px AND zd<3
zx[c]=zx[c]-1
IF zx[c]=px AND zy[c]=py ;//collision player
pe=pe-1
PLAYSOUND (9,0,1)
zx[c]=zx[c]+1
ENDIF
IF m[zx[c]][zy[c]]<>0 //limite
zx[c]=zx[c]+1
ENDIF
ENDIF
IF zy[c]<py AND (zd>2 AND zd<6)
zy[c]=zy[c]+1
IF zx[c]=px AND zy[c]=py ;//collision player
pe=pe-1
PLAYSOUND (9,0,1)
zy[c]=zy[c]-1
ENDIF
IF m[zx[c]][zy[c]]<>0 //limite
zy[c]=zy[c]-1
ENDIF
ENDIF
IF zy[c]>py AND (zd>2 AND zd<6)
zy[c]=zy[c]-1
IF zx[c]=px AND zy[c]=py ;//collision player
pe=pe-1
PLAYSOUND (9,0,1)
zy[c]=zy[c]+1
ENDIF
IF m[zx[c]][zy[c]]<>0 //limite
zy[c]=zy[c]+1
ENDIF
ENDIF
ENDIF
ENDIF
IF zx[c]<>0 AND zy[c]<>0 THEN m[zx[c]][zy[c]]=8 //update map zombie data
SLEEP 5 //delay falso thinking
NEXT
//--- FINISH zomie ROUND
IF tr=2
tr=0
rd=0
kc=0
ENDIF
ENDIF
//--- ZUMBI END---------------------------------------------------------------------------------

IF KEY(59)=1 // turn debug on/off
db=db+1
IF db=3 THEN db=0
kc=0
SLEEP 200
ENDIF


//--- DISPLAY
IF db=1
FOR d=0 TO 31 // DRAW MAP / TABULEIRO debug 1
FOR c=0 TO 31
SETFONT 1
IF c=px AND d=py
PRINT "2",px*14,py*14
ELSE
PRINT m[c][d],c*14,d*14
ENDIF
NEXT
NEXT
PRINT "2",px*14,py*14
ENDIF
IF db=0
FOR d=0 TO 31 // DRAW MAP / TABULEIRO debug 0
FOR c=0 TO 31
SETFONT 1
IF m[c][d]=0 THEN PRINT ".",c*14,d*14
IF m[c][d]=1 THEN PRINT "X",c*14,d*14
IF m[c][d]=3 THEN PRINT ",",c*14,d*14
IF m[c][d]=4 THEN PRINT "T",c*14,d*14
IF m[c][d]=8 THEN PRINT "z",c*14,d*14
PRINT "@",px*14,py*14
NEXT
NEXT
ENDIF
IF db=2
FOR d=0 TO 31 // DRAW MAP / TABULEIRO debug 0
FOR c=0 TO 31
SETFONT 2
IF m[c][d]=0 THEN PRINT ".",c*10,d*14
IF m[c][d]=1 THEN PRINT "X",c*10,d*14
IF m[c][d]=3 THEN PRINT ",",c*10,d*14
IF m[c][d]=4 THEN PRINT "T",c*10,d*14
IF m[c][d]=8 THEN PRINT "z",c*10,d*14
PRINT "@",px*10,py*14
NEXT
NEXT
ENDIF

//debug info
SETFONT 1
PRINT "PLAYER",476,0
PRINT "PX = "+px,476,28
PRINT "PY = "+py,476,42
PRINT "PE = "+pe,476,56
PRINT "PB = "+pb,476,70
PRINT "S  = "+s,476,98
PRINT "BX = "+bx,476,112
PRINT "BY = "+by,476,126

PRINT "SYSTEM",588,0
PRINT "RD = "+rd,588,28
PRINT "TR = "+tr,588,42
PRINT "TC = "+tc,588,56
PRINT "DB = "+db,588,70
PRINT "KC = "+kc,588,84



//--- END GAME / DEAD / VICTORY
IF m[px][py]=3 // exit VICTORY
IF tc=0
PRINT "CLASSE A! VOCE ROUBOU E FUGIU DE BOA! PARABENS",14,476
PLAYSOUND (2,0,1)
SHOWSCREEN
SLEEP 1000
KEYWAIT
END
ENDIF
ENDIF
IF pe<=0 // exit DEAD
PRINT "DANCOU!",196,476
PLAYSOUND (10,0,1)
SHOWSCREEN
SLEEP 1000
KEYWAIT
END
ENDIF

SHOWSCREEN

WEND
// MAINLOOP--------------------------[end]



// MAP DATA
STARTDATA MAPA1:

DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
DATA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
DATA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
DATA 1,0,0,0,0,0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,1,1,1,1,1,1,1,1,1,1,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1

ENDDATA
Title: Re: The Case of Joseph Curwen
Post by: MrPlow on 2014-Nov-19
If you think that's messy - you should see my code!
lol!

Title: Re: The Case of Joseph Curwen
Post by: erico on 2014-Nov-19
hehe, still, it is a lot of fun to do stuff this way, feels like being at the edge of at totally loose code control.
Bugs can be really hard to spot, you get tempted into hacking a solution that makes it even harder further down the road.

For example, on the game, the zombies move in a certain ´speed´ dictated by a SLEEP 15 command.
For some unknown cosmic reason, after you collect a tomb or shoot, they more then double that speed for the rest of the game execution.

I can´t figure why, I think there may be some sort of bug with the SLEEP command called so many times inside loops of for next.
I can´t be sure, I would have to make a snipet to confirm this.
Title: Re: The Case of Joseph Curwen
Post by: Ian Price on 2014-Nov-19
Do you not use FUNCTIONs or TYPEs erico? They can make your code much easier to read and debug.
Title: Re: The Case of Joseph Curwen
Post by: erico on 2014-Nov-19
While I now understand their concept, I need a calm project to practice them and gain confidence on their use. :good:
Title: Re: The Case of Joseph Curwen
Post by: nabz32 on 2014-Nov-19
Quote from: Ian Price on 2014-Nov-19
Do you not use FUNCTIONs or TYPEs erico? They can make your code much easier to read and debug.

I second that!

Thats a good start for a rogue like, altough I wasn´t able to get any T  :'(
I first needed to get used to the 4 turns in a row system and the gun triggering.
Title: Re: The Case of Joseph Curwen
Post by: erico on 2014-Nov-20
Prime idea is that this will be more like x-com, like a tatics game. (finalfantasy tatics, ogre battle).
I guess I used the term rogue in a wrong way here.

Thank you all for giving a go. :)
Title: Re: The Case of Joseph Curwen
Post by: Ian Price on 2014-Nov-20
TBS - Turn Based Strategy is a particular fave genre of mine, so looking forward to seeing more :)
Title: Re: The Case of Joseph Curwen
Post by: bigsofty on 2014-Nov-20
Looks good Erico, same as Ian, I'm a big fan of TBS.  :good:
Title: Re: The Case of Joseph Curwen
Post by: erico on 2015-Jul-24
Not much happened on this game as I thought to rewrite it and clean code.
But I did poke with level creation these past months and came up with some pleasant outcomes.

Here some screenies of the output.
I´m working with a 10x10 zones where each contains 5x5 blocks (16x16 pixels each).
Yeah all 2 colors black and white gfx.

I first work with the plotting zones, then I look into its content and finally, I run through the whole map a few times block by block doing final touches.

edit: the thing looks a bit RND and that is because the final output is to be an ancient forgotten sematary in the woods. It fits the purpose of the game when the light sistem is on. Still, this map generator is somehow code configurable. :P

Title: Re: The Case of Joseph Curwen
Post by: Ian Price on 2015-Jul-24
I'd forgotten all about this. Good to see that progress is on-going :)
Title: Re: The Case of Joseph Curwen
Post by: erico on 2015-Jul-29
I thought I´d let you know how maps get drawn here:
-generate 50x50 map array.
-generate 10x10 zone array.
[The zone array was first created to work with pre-made blocks that would get created on an specific 5x5 array before getting plotted on the map but I ditched the idea since I thought that for my wanted output, this would be overkill.]
[Also, 1 zone on each side is more or less a dead one, I generate over it but you won´t be able to go into it on the final game, it is just done so that the map dosen´t have visual dead/empty boundaries , like when you get on the border things just don´t disappear, you have some 5 blocks of ´scenary´. The other reason was that I didn´t wanna bother with array limits while dealing the map, ye no out of bound calls. So the safe zone is actually 8x8]
-generate a start zone on the lower part of the safe zone skipping 1 extra zone each side.
-here comes a very strange algorithm to draw a path like a snake from the start zone, I avoid backtrack and diagonal movements.
-then I pick a random zone within this path and a random clear map zone and connect them, here diagonals are allowed.
-These ones are now called path zones, I RND some ground textures on the equivalent map.
-On the non-path zones, I RND some high density zones (the brow darker ones).
-I run trough the zone array checking for high density zones and draw mid density ones on each side if it is not a path zone.
-All other clear zones, non-path ones, becames low density zones...enough of zones ::) jump to map array.
-RND bricks according to density on the map array.
-Run 2x a 2x2 diagonal analyses on the map checking for diagonal bricks and changing the lower ones to broken bricks, here I´d like to avoid diagonal brick blocks.
-Run a cross check on each non-brick tile to kill single spaces enclosed by bricks. Double or more remains.
-Run horizontal check looking for bricks that are 1 to 5 empty tiles apart and draw metal fence, RND broken ones. I also check up and down so fences don´t get drawn stacked over each other.
-Generate graves, destroyed graves, lamps.
-RND trees all over.
-Run through the map growing each tree tile on its sides if empty, do that again.
-Run through the map growing leaves tiles around the tree tiles if empty, do that again.
-Voila, there is the map. :)

It may look a bit noisy but it fits the game needs as I want to depict an abandoned ancient graveyard.
I should upload a gif of it working, but it dosen´t show much, some steps are a bit invisible to showscreen.

I got inspired by this article here on Brogue on map generation, take a read:
http://www.rockpapershotgun.com/2015/07/28/how-do-roguelikes-generate-levels/#more-303483
Title: Re: The Case of Joseph Curwen
Post by: nabz32 on 2015-Jul-29
Wow nice insight erico,

thx!
Title: Re: The Case of Joseph Curwen
Post by: erico on 2015-Jul-30
Thanks Nabz, did you check the brogue link?
I have tried to do some homework on map generation for inspiration and that article just came out yesterday, very inspiring stuff.
It is nice to see people´s approach on the subject, I have a crush for rogue games.
Say, that is one kind of game that could even beat the author. :)
Cheers. :good:
Title: Re: The Case of Joseph Curwen
Post by: nabz32 on 2015-Jul-30
That article is amazing, a lot of insight is given there on random map creation.
After having taken that "graphs and optimizing" course at our college I am eager to
try out some of the optimized pathfinding algorythms.

Maybe I could add a random map generation function to my level editor.
Title: Re: The Case of Joseph Curwen
Post by: Hemlos on 2015-Aug-02
I got 4 t's

Erico....Ercio....Erico

We need you to master TYPE!
We wouldnt steer you wrong brother, use them, they will unlock your imagination and unleash your amazing art skills!
Youre looking for time shortcuts? ...TYPE is #1
You see, it will not only simplify your ideas in an orderly way, but itll also allow you change the entire game if you change the rules.
Title: Re: The Case of Joseph Curwen
Post by: erico on 2015-Aug-02
I will get there Hemlos! :good: