baconman
|
|
« Reply #6 on: October 15, 2014, 08:44:32 PM » |
|
This is the code that runs once, at the beginning of each "game." The idea is that it takes one list (0, 0, 0, 1, 2, 4, 8, 16, 32) and shuffles it. The first 3 resulting in the shuffle are added together to make 3 layers of obstructions, and then the fourth makes a "streampath," which I associate with liquids and spikes and so forth. The idea is that this output makes something like "room number; total obstructions; stream path" in another list, for the "screen coder" to reference. Really, it should produce one list like (screen id, obstruction) and a second list like (screen id, stream path). These are referenced in the "oRoomCreateCode" object, persistently on the screen. The whole game just takes place on one screen, really. //makes two arrays of 225 rooms: //ds_list(rooms_array) fills the screen with barricades, according to its' calculation... //ds_list(room_streams) creates the gaps/fluids in the screens according to that one's.
variable_global_set(screenlist, 0) //variable_global_set(roomfill_id, 0) //variable_global_set(room_streams, 0) //variable_global_set(rooms_array, 0)
roomfill_id = ds_list_create() //make a list for the room-fillers rooms_array = ds_list_create() //and one for the list of the totals room_streams = ds_list_create() //one for the streams screenlist = ds_list_create() //one to identify the screen might be useful too, come to think of it... ^.^' DERP!!
var screens //total number of screens variable_local_set(totalrooms, 0) //9 sub-grids of 5 x 5 maps?
ds_list_add(roomfill_id, 0) //populate the list ds_list_add(roomfill_id, 0) ds_list_add(roomfill_id, 0) ds_list_add(roomfill_id, 1) ds_list_add(roomfill_id, 2) ds_list_add(roomfill_id, 4) ds_list_add(roomfill_id, 8) ds_list_add(roomfill_id, 16) ds_list_add(roomfill_id, 32)
var screen //just a variable to give each screen a numerical value, like the enum command var roomfill //declare a variable, define it with the first three of the shuffled results var streampath
for (screens = 255 ; screens = 0; screens -= 1) { variable_local_set(screen, screen + 1) ds_list_add(screenlist, screen) { ds_list_shuffle(roomfill_id) //shuffle the IDs, make them mix up return roomfill = ds_list_find_index(roomfill_id, argument0) + ds_list_find_index(roomfill_id, argument1) + ds_list_find_index(roomfill_id, argument2) return streampath = ds_list_find_index(roomfill_id, argument3) ds_list_add(rooms_array, roomfill) ds_list_add(room_streams, streampath) } } game_save(world.map) Then, the second part is a seperate script, meant to deconstruct those variables and populate the screens according to their relative ID. Each power of two creates a particular obstacle layer, which is determined by the "level" associated with the zone. Once I can actually get this much of it running properly, then I'm going to adjust the doorway collision to reference correct zones of 25 screens per group (the screens themselves are 15 tiles wide, 9 tiles tall, not counting exterior walls; and the tiles are 32x32 px). You can see how this stuff lines up in the "room1-action" room. This part will run every time you cross one "screen" into another, to construct the room associated with it's screen id. var barrier //declare some barriers according to the level? var stream var level
//define the "level" switch(ds_list_find_index(screenlist, screenid)) { case 0..24: variable_local_set(level, 3) //NW section case 25..49: variable_local_set(level, 4) //NC section case 50..74: variable_local_set(level, 2) //NE section case 75..99: variable_local_set(level, 1) //WC section case 100..111: variable_local_set(level, 0) //start section 1 case 112: variable_local_set(level, 5) //Home Screen, invalid on purpose!! Player begins here. case 113..124: variable_local_set(level, 0) //start section case 125..149: variable_local_set(level, 1) //EC section case 150..174: variable_local_set(level, 3) //SW section case 175..199: variable_local_set(level, 4) //SC section case 200..224: variable_local_set(level, 2) //SE section } //define what the barrier for the level is //if irandom(750) = 1 //randomly disburse Tinted Rocks? //then return oTintRock //else switch(level) { case 0: variable_local_set(barrier, oBush) variable_local_set(stream, oWater) case 1: variable_local_set(barrier, oRock) variable_local_set(stream, oHole) case 2: variable_local_set(barrier, oStatueB) variable_local_set(stream, oPoison) case 3: variable_local_set(barrier, oStatueA) variable_local_set(stream, oSpikes) case 4: variable_local_set(barrier, oSpikeTile) variable_local_set(stream, oLava) case 5: instance_create(240, 240, oStartChest) instance_create(368, 240, oStartChest) } //fill and populate the rooms according to the results!
//first, the barriers (since "streams" will overwrite them)
ds_list_find_value(rooms_array, screenid)
if roomfill = 0 //tag as a special room! Write the special room manually, then set the roomfill/streampath = 0.
then { instance_create(240, 128, oNPC) //NPC will randomize, and determine special room properties instance_create(176, 128, oBonfire) instance_create(304, 128, oBonfire) } else { instance_create(112, 176, oEnemySpawn) instance_create(112, 368, oEnemySpawn) instance_create(304, 272, oEnemySpawn) instance_create(304, 272, oItemSpawn) instance_create(496, 176, oEnemySpawn) instance_create(496, 368, oEnemySpawn) } continue
//spawn enemies in the 5 corner/center locations, according to level and openness //item spawner is in the center, too
//fill the barriers!
if roomfill >= 32
then instance_create(272, 160, barrier) roomfill -= 32 continue
if roomfill >= 16
then instance_create(176, 208, barrier) instance_create(144, 240, barrier) instance_create(112, 272, barrier) instance_create(144, 304, barrier) instance_create(176, 336, barrier) instance_create(336, 208, barrier) instance_create(368, 240, barrier) instance_create(400, 272, barrier) instance_create(368, 304, barrier) instance_create(336, 336, barrier) roomfill -= 16 continue
if roomfill >= 8
then instance_create(112, 208, barrier) instance_create(112, 336, barrier) instance_create(432, 208, barrier) instance_create(432, 336, barrier) roomfill -= 8 continue
if roomfill >= 4
then instance_create(176, 304, barrier) instance_create(208, 304, barrier) instance_create(272, 304, barrier) instance_create(304, 304, barrier) roomfill -= 4 continue
if roomfill >= 2
then instance_create(272, 208, barrier) instance_create(240, 240, barrier) instance_create(304, 240, barrier) instance_create(208, 272, oBush) instance_create(336, 272, barrier) instance_create(240, 304, barrier) instance_create(304, 304, barrier) instance_create(272, 336, barrier) roomfill -= 2 continue
if roomfill >= 1
then instance_create(176, 272, barrier) instance_create(336, 272, barrier) roomfill -= 1 continue
//barrier setup is complete, now it's time for the stream placement
ds_list_find_value(room_streams, screenid)
if streampath >= 32
then instance_create( 80, 208, stream) instance_create( 80, 240, stream) instance_create( 80, 272, stream) instance_create( 80, 304, stream) instance_create(208, 368, stream) instance_create(240, 368, stream) instance_create(272, 368, stream) instance_create(272, 336, stream) instance_create(272, 304, stream) instance_create(272, 272, stream) instance_create(272, 240, stream) instance_create(272, 208, stream) instance_create(272, 176, stream) instance_create(304, 176, stream) instance_create(336, 176, stream) instance_create(464, 240, stream) instance_create(464, 272, stream) instance_create(464, 304, stream) instance_create(464, 336, stream)
streampath -= 32 continue
if streampath >= 16
then instance_create(144, 208, stream) instance_create(144, 240, stream) instance_create(144, 272, stream) instance_create(144, 304, stream) instance_create(176, 304, stream) instance_create(204, 304, stream) instance_create(240, 304, stream) instance_create(240, 336, stream) instance_create(240, 368, stream) instance_create(304, 176, stream) instance_create(304, 208, stream) instance_create(304, 240, stream) instance_create(336, 240, stream) instance_create(368, 240, stream) instance_create(400, 240, stream) instance_create(400, 272, stream) instance_create(400, 304, stream) instance_create(400, 336, stream) streampath -= 16 continue
if streampath >= 8
then instance_create(144, 176, stream) instance_create(144, 208, stream) instance_create(172, 176, stream) instance_create(172, 208, stream) instance_create(368, 176, stream) instance_create(368, 208, stream) instance_create(400, 176, stream) instance_create(400, 208, stream) instance_create(144, 336, stream) instance_create(144, 368, stream) instance_create(172, 336, stream) instance_create(172, 368, stream)
instance_create(368, 336, stream) instance_create(368, 368, stream) instance_create(400, 336, stream) instance_create(400, 368, stream) streampath -= 8 continue
if streampath >= 4
then instance_create( 48, 144, stream) instance_create( 80, 144, stream) instance_create(112, 144, stream) instance_create(144, 144, stream) instance_create( 48, 176, stream) instance_create( 80, 176, stream) instance_create(112, 177, stream) instance_create( 48, 336, stream) instance_create( 48, 368, stream) instance_create( 80, 368, stream) instance_create( 48, 400, stream) instance_create( 80, 400, stream) instance_create(112, 400, stream) instance_create(144, 400, stream) instance_create(400, 144, stream) instance_create(432, 144, stream) instance_create(464, 144, stream) instance_create(496, 144, stream) instance_create(464, 176, stream) instance_create(496, 176, stream) instance_create(496, 176, stream) instance_create(496, 336, stream) instance_create(464, 368, stream) instance_create(496, 368, stream) instance_create(400, 400, stream) instance_create(432, 400, stream) instance_create(464, 400, stream) instance_create(496, 400, stream) streampath -= 4 continue
if streampath >= 2
then instance_create(208, 208, stream) instance_create(176, 208, stream) instance_create(144, 208, stream) instance_create(144, 240, stream) instance_create(144, 240, stream) instance_create(144, 304, stream) instance_create(144, 336, stream) instance_create(176, 336, stream) instance_create(208, 336, stream) instance_create(336, 208, stream) instance_create(368, 208, stream) instance_create(400, 208, stream) instance_create(400, 240, stream) instance_create(400, 272, stream) instance_create(400, 304, stream) instance_create(400, 336, stream) instance_create(368, 336, stream) instance_create(336, 336, stream) streampath -= 2 continue
if streampath >= 1
then instance_create(208, 272, stream) instance_create(240, 272, stream) instance_create(272, 272, stream) instance_create(304, 272, stream) instance_create(336, 272, stream) streampath -= 1 continue
I still don't know what's making it not work, though. The error I get is an "unknown variable" error, in spite of it being a global variable... ___________________________________________ ERROR in action number 2 of Other Event: Room Start for object oRoomCreateCode:
In script fillRoom2: Error in code at line 6: switch(ds_list_find_index(screenlist, screenid)) ^ at position 28: Unknown variable screenlist
|