that is my first attempt of doing some dungeons

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
pch
Prole
Posts: 32
Joined: Sun Mar 04, 2012 5:17 pm
Location: poland

that is my first attempt of doing some dungeons

Post by pch »

Hello, I'm new here and a programming thing is quite new to me as well (but I know how to make formulas in excel quite good and did some *.bat scripts before only such "big" project is totaly new to me)
Anyway I decided to give it a try and I managed to make something wich works:

rooms are generated and connected (bsp file)
path finding algoritm is done (astar file)
monsters are moving with different speed (monsterMove file)

as i said - first try (but it took me week to make it:) )
At first I was a little afraid of posting it here but otherwise I wouldn't learn much so if you guys have a time then pls take a look at this and point out all things I did wrong (probably 90%)

the file is quite big because fonts are included (DejaVuSansMono.ttf)

you can move with arrows
generate new level with enter
display a path to the exit with 2
quit with escape
nothing else.

Thank You.
Attachments
outline.love
(191.05 KiB) Downloaded 70 times
Last edited by pch on Wed Mar 07, 2012 6:51 pm, edited 1 time in total.
User avatar
Ellohir
Party member
Posts: 235
Joined: Sat Oct 22, 2011 11:12 pm

Re: that is my first attempt of doing some dungeons

Post by Ellohir »

It crashes when you are on the exit and try to calculate the way to the exit xD Otherwise it works flawlessly, nice job :awesome:
User avatar
pch
Prole
Posts: 32
Joined: Sun Mar 04, 2012 5:17 pm
Location: poland

Re: that is my first attempt of doing some dungeons

Post by pch »

oh man!
I wouldn't even think of that :)
thanks for checking!
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: that is my first attempt of doing some dungeons

Post by coffee »

Ah, the very beggining of an ascii roguelike engine. Simple, good. Till now didn't notice problems. I will like study your astar and bsp engines. Nice work! :)
User avatar
pch
Prole
Posts: 32
Joined: Sun Mar 04, 2012 5:17 pm
Location: poland

Re: that is my first attempt of doing some dungeons

Post by pch »

that would be very nice!

astar is quite simple - I found tutorial and then I took a piece of paper and made a grid and found out how it works. I did 4 versions - this one is far the fastest one - so I kept it.

bsp is a mess - i found an article on wiki and tried to make it work - room generator is fine (I think) but I had a lot of trouble with corridors - most likely it can be much simpler - sorry but there are no coments (just a couple)
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: that is my first attempt of doing some dungeons

Post by coffee »

pch wrote:that would be very nice!

astar is quite simple - I found tutorial and then I took a piece of paper and made a grid and found out how it works. I did 4 versions - this one is far the fastest one - so I kept it.

bsp is a mess - i found an article on wiki and tried to make it work - room generator is fine (I think) but I had a lot of trouble with corridors - most likely it can be much simpler - sorry but there are no coments (just a couple)
Your astar is quite simple but is working well and I think calculating "rogue" diagonals as It should . Simple suggestion. When Astar active why don't "realtime" recalculate path when you move? A cool thing could be using "tab" or other key for generate instead alt path between player and enemies. Also, since you had path finding done instead of random move why not introduce a chasing mode for mobs?

your bsp is more hard to read but also seems be random generating well with some bigger rooms ocasional. I liked.
User avatar
pch
Prole
Posts: 32
Joined: Sun Mar 04, 2012 5:17 pm
Location: poland

Re: that is my first attempt of doing some dungeons

Post by pch »

no more crashes when player is already standing on exit.

I just changed it slightly so now TAB toggles player->exit path on/off and the path is being calculated after every key press.

When I did the same to all monsters (path monster->player) my notebook died :) (it's gma500 with atom z550) - one move took ~3 sec (when 15 monsters were present).

I will definitely try correcting this but first would like to ask if storing a map in "layers" is good idea. Something like this:
map[y][x][1]-walls
map[y][x][2]-floors
map[y][x][3]-"furnitures"
map[y][x][4]-monsters
...

how can I simplyfy that long lines in love.draw - they are long because I keep player in the center. Is there another way of doing it?

also I'd like to ask if somebody is willing to rewrite attached astar code (it's very short) making it look a little bit more "pro" - that'd be a great way to understand this kind of writing and learn a little more.

Thanks
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: that is my first attempt of doing some dungeons

Post by coffee »

pch wrote: When I did the same to all monsters (path monster->player) my notebook died :) (it's gma500 with atom z550) - one move took ~3 sec (when 15 monsters were present).
to all??? I wasn't for sure thinking you do such, just "tab" to cycle between entities and draw a path between you and one selected enemy.

I don't have yet experience with path finding so I'm not the right guy to do that. But did you already checked other LOVE nice path findings? You have Roland_Yonaba's old engine viewtopic.php?f=5&t=3459, Marekk's Pie viewtopic.php?f=5&t=7174, kikito's new pulsar
viewtopic.php?f=5&t=7983. All great engines and with nice discussions about that matter.

About the layers it's important but I personally don't use so many layers. I use a more real physical aproach (Ground/Above Ground) and don't consider monsters as belonging to map type (but a lot of people do it that way). Also since furnitures can't usually overlap walls I don't have necessity of use different layers. But can be handy for some map layouts (like cuckoo clock in the wall). If you feel confortable with that layout go ahead, as long it suits you. :)

EDITED About your movement it's more elegant do a generic "move" function. Send coordinates where you want to move. This style

Code: Select all

		  if p_key == 'q' or p_key == 'kp7' and hero.y-1 > 0 and hero.x-1 > 0 then
			 hero.move (-1,-1)
		  end/else
Also you can reroute there in hero.move if the place where you want to move have a mob (and so attack, it's a void, moving wall, door) etc...
User avatar
pch
Prole
Posts: 32
Joined: Sun Mar 04, 2012 5:17 pm
Location: poland

Re: that is my first attempt of doing some dungeons

Post by pch »

thanks for the links and explanation - will check them (links) right away and will think over my approach.

well, yes - one monster or just a bunch of them whithin small range should work :)

i've started reading some FOV (field of view), LOS (line of sight) tutorials so I'd like to include it there (but at the moment it just scares me off).

eta:
haven't seen your sugestion about movement - will check it out
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: that is my first attempt of doing some dungeons

Post by coffee »

pch wrote:thanks for the links and explanation - will check them (links) right away and will think over my approach.

well, yes - one monster or just a bunch of them whithin small range should work :)

i've started reading some FOV (field of view), LOS (line of sight) tutorials so I'd like to include it there (but at the moment it just scares me off).

eta:
haven't seen your sugestion about movement - will check it out
You could try read this awesome resource http://www-cs-students.stanford.edu/~am ... html#paths

About tun based FOV/LOS in LOVE
viewtopic.php?f=5&t=1797
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 0 guests