Create regions in a checked pattern ? :S

Komaqtion

You can change this now in User CP.
Reaction score
469
Hellu ! ;)

Ok, so I just wanted to know, how can I create a region in every square, in a check pattern ? :S

Ok, so with this code below I've created a checked pattern (Like a Chess board, but it isn't :p), and I was wondering what the easiest way it to create a region in those squares that are creates :S

I've already "started" with something at the bottow, but I stopped as I didn't know what I was doing XD

JASS:
scope TerrainPattern initializer Create_Checked_Pattern

    globals
        constant real CENTER_X = 0
        constant real CENTER_Y = 0

        private constant real SQUARE_WIDTH = 8192.
        private constant real SQUARE_HEIGHT = 8192.

        private constant real COLUMNS = 19.
        private constant real ROWS = 19.

        private constant integer BORDER_RES = 200
        private constant string SFX_PATH = "Abilities\\Spells\\Human\\SpellSteal\\SpellStealMissile.mdl"

    endglobals

    globals
        rect array BoxCol
        rect Board = Rect( CENTER_X - ( SQUARE_WIDTH / 2 ), CENTER_Y - ( SQUARE_HEIGHT / 2 ), CENTER_X + ( SQUARE_WIDTH / 2 ), CENTER_Y + ( SQUARE_WIDTH / 2 ) )
    endglobals

    private function Create_Checked_Pattern takes nothing returns nothing
        local real posx
        local real posy
        local real x
        local real y
        local real width = SQUARE_WIDTH / COLUMNS
        local real height = SQUARE_HEIGHT / ROWS

        local integer ic
        local integer ir
        
        local integer i = 0
        
        loop
            exitwhen i >= 12
            call FogModifierStart( CreateFogModifierRect( Player(i), FOG_OF_WAR_VISIBLE, bj_mapInitialPlayableArea, true, true ) )
            
            set i = i + 1
        endloop

        set i = 1
        set posx = CENTER_X - ( SQUARE_WIDTH / 2 )
        set posy = CENTER_Y + ( SQUARE_HEIGHT / 2 )
        set ic = 0
        
        loop
            exitwhen ( ic == COLUMNS + 1 )
            
            set x = posx + ( ic * ( SQUARE_WIDTH / COLUMNS ) )
            set y = posy
            set ir = 0
            
            loop
                exitwhen ( ir == BORDER_RES + 1 )
                
                set y = ( posy - ( ir * ( SQUARE_HEIGHT / BORDER_RES ) ) )

                call AddSpecialEffect( SFX_PATH, x, y )

                set ir = ir + 1
            endloop

            set ic = ic + 1
        endloop

        set ir = 0
        
        loop
            exitwhen ( ir == ROWS + 1 )
    
            set x = posx
            set y = posy - ( ir * ( SQUARE_HEIGHT / ROWS ) )
            set ic = 0
            
            loop
                exitwhen ( ic == BORDER_RES + 1 )
                
                set x = ( posx + ( ic * ( SQUARE_WIDTH / BORDER_RES ) ) )
                
                call AddSpecialEffect( SFX_PATH, x, y )
                
                set ic = ic + 1
            endloop
    
            set ir = ir + 1
        endloop
        
        loop
            exitwhen i >= ( ( SQUARE_HEIGHT * SQUARE_WIDTH ) / 2 )
            
            set BoxCol<i> = Rect( ( i - 1 ) * width, ( i - 1 ) * height, i * width, i * height )
                
            call SaveInteger( Boxes, 1, GetHandleId( BoxCol<i> ), BoxData.create( BoxCol<i> ) )
            
            set i = i + 1
        endloop
    
    endfunction

endscope</i></i></i>


Any ideas ? :eek:
 

Executor

I see you
Reaction score
57
JASS:
globals
    constant integer COLUMN_COUNT   = 5
    constant integer ROW_COUNT      = 5
    constant real    SQUARE_EDGE    = 120.
    constant real    SQUARE_SPACE   = 40.
    constant real    SQUARE_STEP    = SQUARE_EDGE + SQUARE_SPACE
    constant real    FIELD_STARTX   = 0.
    constant real    FIELD_STARTY   = 0.
endglobals

struct IndexedRect
    rect r
endstruct

function Test takes nothing returns nothing
    local integer c = 0
    local integer r = 0
    
    local real x    = 0.
    local real y    = 0.
    
    loop
        exitwhen c == COLUMN_COUNT
        
        set x = FIELD_STARTX + c * SQUARE_STEP
        
        set r = 0
        loop
            exitwhen r == ROW_COUNT
            
            set y = FIELD_STARTY + r * SQUARE_STEP
            
            set IndexedRect.create().r = Rect(x,y,x+SQUARE_EDGE,y+SQUARE_EDGE)
            
            set r = r + 1
        endloop
        set c = c + 1
    endloop
endfunction

//  ................ = STEP
//        ...        = SPACE
//  .......          = EDGE
//  _______  _______
//  |     |  |     |
//  |     |  |     |
//  |_____|  |_____|


shouldn't sth. like this work, or am I misunderstanding you?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top