Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Tutorial - Making the map bigger
- - By Ezrick Date 2012-01-24 02:45
So I am generally new to programming, and understand the tutorial pretty well. I understand the stars and spaceship. The animation part is a little confusing but I'll get to that later.

So I want to make the map on the game many times larger.  The window should stay focused on the ship. This is a start. From here I want to add a minimap, some bad guys (saw a post somewhere about this one), powerups, and whatever else I get to. So my problem is how to draw a larger map.

I opened up cptnruby to see how the map was generated and how the window behaves. I assume its in Map.draw.  I barely understand whats going on here and am hoping for a little more explanation. Some other examples would be much appreciated too if possible.

@height.times do |y|
      @width.times do |x|
        tile = @tiles[x][y]
        if tile
          @tileset[tile].draw(x * 50 - 5, y * 50 - 5, 0)
        end
      end
    end

I get this part. For each tile you loaded form the txt, draw it in the right place. My question here is if this means that each image, in this case Image.load_tiles, has an inherent draw function. Anyways any help would be appreciated. Just try and steer me in the right learning direction.
Parent - By MCMayor Date 2012-01-24 07:26
Every image can draw itself. See http://www.libgosu.org/rdoc/Gosu/Image.html#draw-instance_method
The code there probably set @tileset to a list of Images. Image.load_tiles is a list and has no draw function, but each element in it (accessed by @tileset[tile]) does.

So his code says:
For each map position:
..get tilecode at this position
....if tilecode is not nil (if there is a tile at this space)
......get image for tile code
......tell image to draw at geometric position (map_x*50-5, map_y*50-5)
Up Topic Gosu / Gosu Exchange / Tutorial - Making the map bigger

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill