Results 1 to 10 of 14

Thread: loading set from file

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    I know that using strings for naming block types might look easier but in the end it only complicates things not to mention that operating with strings is ususally slower.
    So I advice you to use numbers for defining your block type. Why? Becouse with numbers you can quickly kinda divide all of your block types into sets.
    Take a look at next example of block definition:
    Code:
    //Pseudocode
    
    //Passable blocks: 0-100
    begin
      0 = air
      1 = water
      2 = background wall
      3 = doors
      ....
    end
    
    //Unpassable blocks 100-900
    begin
      //Destructable blocks
      begin
        //Ground 100-199
        begin
          100 = dirt
          101 = grass
          102 = stone
          ...
        end
        //Minerals 200-300
        begin
          200 = iron
          201 = coal
          202 = coper
          ...
        end
      //Undestructable blocks 900-1000
      begin
        901 = bedrock
      end
    end
    In the end you can also define numeric sets in form of btMinerals: 201..300. This alows you to change the block definition types at any time without the need to recompile your program and still use sets to quickly determine block type.
    Last edited by SilverWarior; 17-07-2013 at 06:06 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •