Creating "Blueprint" for rooms

S

Simulacron

Guest
I'm working on a game, where the level gets randomly generated out of little room tpyes like cooridors, normal rooms, staircases, etc. These are all in one gamemaker room. My level generation works so far, but at the moment I just use one sprite for each room, just to see if the level generation is working. Now I want to replace this sprite with a room, build out of multiple objects, but it would be very long-winded to code each room (f.ex. saying that at pos 0,0 obj_wall gets created, at pos 0,1 another wall,...) Is there a faster way of doing this? Can I somehow save room layouts in a data-type or could I use an image, where each pixel stands for an object and the color detemines which object gets created?
Thanks in advanced!
 

ph101

Member
You need to design a system of storing the layout of each room type and then creating the objects. Personally I would probably look at creating a grid to store a number that equates to an object type, then you read through the grid and create saide object at the position. Then you could have different grids to make different layouts perhaps. There was a thread about this recently, you need to search about procedural room generation. https://forum.yoyogames.com/index.php?threads/authored-procedural-generation.23988/#post-149745
 
S

Simulacron

Guest
At the moment I'm trying to get the darw_getpixel_ext() function to works, but it alsways gives me the same 32bit value.
I use the following code in the draw event:
Code:
color = draw_getpixel_ext(mouse_x,mouse_y)
draw_text(64,32,color)
But it always gives me the value of the background. I checked that the object, that has the sprite I want to check in it, gets created before the object that does the checking.
It probably has something to do with this advice given in the manual:
With this function you can get the full abgr 32bit value of any pixel that is being drawn to the current render target. This means that the results will depend on the event in which the function is called, and also on the target surface being used.
But I don't know in which function to put it or how to change the target surface.
 
Top