Infinite Space Example

Home - Extensions - Scripts - Games - Examples

This is an example of infinite space. The player can travel through it forever and ever. Why is this useful, you may ask? You can use it to make mind-bogglingly big rooms without having a mind-bogglingly big room. For example, say I wanted to make a game where you control a ship that flies through space. I want space to be big. I can put the entire game (or at least the part where you fly around) into one room, without the room being any bigger than the view.

The example is highly commented, and very easy to use. You put one code-block in the end step event, and it takes care of the rest. You won't even know it exists, since you can use speed and direction just like you normally do. Any homing missiles you have will move normally, and so will any bullets. All this is automatic.

System 1 Info:
This system works by moving all objects but the player. It allows for gigantic rooms, but requires some extra work on the developer's side. Particles, backgrounds, position-based deactivation, and effects may require extra effort with this system. Very doable.

System 2 Info:
This system allows for rooms 4 times larger than GM's max size. It is easy to use, and works by forcing the view to follow the player. It has problems with tiled backgrounds, but other than that, it works like a charm. To fix the background problems, create a background object and give it code something like this:

if x < view_xview[0] x += back_w
if x > view_xview[0]+view_wview[0] x -= back_w
if y < view_yview[0] y += back_h
if y > view_yview[0]+view_hview[0] y -= back_h

draw_sprite(sprite_index,0,x,y)
draw_sprite(sprite_index,0,x-back_w,y-back_h)
draw_sprite(sprite_index,0,x-back_w,y)
draw_sprite(sprite_index,0,x,y-back_h)

There! Just replace back_h and back_w with the width and height of the background and use a sprite (or background) that is the same size or larger than the view.

Stats:
GM max room area:
999998000001
System 1 max room area (3e+606x larger):
3e+618 (Bigger than anyone could ever need)
System 2 max room area (4x larger):
3999992000004

Download:

GMC Link 

Download System 1

Download System 2

web metrics