FAQ  •  Register  •  Login

coordinate picker help

<<

tazinator

Posts: 351

Joined: Fri Jul 05, 2013 7:35 pm

Post Mon Mar 31, 2014 2:04 am

coordinate picker help

I need a levelgen that can pick x number of coordinates out of y number of coordinates, and feed them into the following


Right now I have this.

  Code:
-- five each: resource items, repair items, energy items, test items
-- their position in the maze should be randomized from coords
local repair = RepairItem.new
repair:setRegenTime(20)
local energy = EnergyItem.new
energy:setRegenTime(20)
local resource = ResourceItem.new
local bouncy = TestItem.new


 

  Code:

3442.5 1912.5 20
2932.5 2422.5 20
2422.5 2932.5 20
2422.5 2422.5 20
3442.5 2422.5 20
3442.5 2932.5 20
1912.5 1912.5 20
2422.5 1912.5 20
2932.5 1912.5 20
3952.5 1912.5 20
3952.5 2422.5 20
2932.5 2932.5 20
1912.5 2932.5 20
1912.5 2422.5 20
1912.5 3952.5 20
2422.5 3952.5 20
2932.5 3952.5 20
3952.5 2932.5 20

2932.5 1402.5 20
2422.5 1402.5 20
1912.5 892.5 20
2422.5 892.5 20
2932.5 892.5 20
1912.5 1402.5 20
1402.5 2422.5 20
892.5 2422.5 20
892.5 1912.5 20
1402.5 1912.5 20

892.5 2932.5 20
1402.5 2932.5 20
1912.5 382.5 20
2422.5 382.5 20
2932.5 382.5 20
1912.5 4462.5 20
2422.5 4462.5 20
2932.5 4462.5 20
1912.5 4972.5 20
2422.5 4972.5 20
2932.5 4972.5 20
382.5 2422.5 20
382.5 1912.5 20
382.5 2932.5 20
4462.5 2422.5 20
4462.5 1912.5 20
4462.5 2932.5 20
4972.5 2422.5 20
4972.5 1912.5 20
4972.5 2932.5 20
1912.5 3442.5 20
2422.5 3442.5 20
2932.5 3442.5 20
 

I'm thinking 20 coordinates are all I need (that isn't set in stone) - I have too many and need a picker
I'm actually not sure how I'll put these coordinates into the level either
bad case scenario I do this
energy1:setPos
bf:addItem(energy1)
energy2:setPos()
bf:addItem(energy2)
energy3:setPos()
bf:addItem(energy3)
energy4:setPos)()
bf:addItem(energy4)
energy5:setPos()
bf:addItem(energy5)

repair1:setPos()
repair2:setPos()
repair3:set... etc
(yeah that would suck)

worst case scenario I just put them in in set places, every time. sure would be easier :lol:
Play my new level! Two different teams fight over a nexus: One mainly defends while the other attacks! is fun
viewtopic.php?f=33&p=21002#p21002
<<

bobdaduck

User avatar

Global Moderator

Posts: 789

Joined: Thu Mar 11, 2010 1:39 pm

Location: Utah

Post Mon Mar 31, 2014 10:12 am

Re: coordinate picker help

Yo. Check it.
  Code:
pickerList = {
    point.new(3442.5, 1912.5),
    point.new(2932.5, 2422.5),
    point.new(2422.5, 2932.5),
    point.new(2422.5, 2422.5),
    point.new(3442.5, 2422.5),
    point.new(3442.5, 2932.5),
    point.new(1912.5, 1912.5),
    point.new(2422.5, 1912.5),
    point.new(2932.5, 1912.5),
    point.new(3952.5, 1912.5),
    point.new(3952.5, 2422.5),
    point.new(2932.5, 2932.5),
    point.new(1912.5, 2932.5),
    point.new(1912.5, 2422.5),
    point.new(1912.5, 3952.5),
    point.new(2422.5, 3952.5),
    point.new(2932.5, 3952.5),
    point.new(3952.5, 2932.5),

    point.new(2932.5, 1402.5),
    point.new(2422.5, 1402.5),
    point.new(1912.5, 892.5),
    point.new(2422.5, 892.5),
    point.new(2932.5, 892.5),
    point.new(1912.5, 1402.5),
    point.new(1402.5, 2422.5),
    point.new(892.5, 2422.5),
    point.new(892.5, 1912.5),
    point.new(1402.5, 1912.5)
}
-- five each: resource items, repair items, energy items, test items
-- their position in the maze should be randomized from coords
function pickFromPickerList()
    local roll = math.random(#pickerList) --# takes the size of an array
    local pointToReturn = pickerList[roll] --This is for protection after the next line.
    table.remove(pickerList, roll) --I assume here there shouldn't be overlap between any objects.
    return pointToReturn
end
function main()
    for i = 0, 5 do --Resource Items
        local res = ResourceItem.new()
        local pos = pickFromPickerList()
        res:setPos(pos)
        bf:addItem(res)
        logprint("added res at " .. tostring(pos))
    end

    for i = 0, 5 do --Repair Items
        local repair = RepairItem.new()
        repair:setRegenTime(20) 
        local pos = pickFromPickerList()
        repair:setPos(pos)
        bf:addItem(repair)
        logprint("added repair at " .. tostring(pos))
    end

    for i = 0, 5 do --Energy items
        local energy = EnergyItem.new()
        energy:setRegenTime(20)
        local pos = pickFromPickerList()
        energy:setPos(pos)
        bf:addItem(energy)
        logprint("added energy at " .. tostring(pos))
    end
   
    for i = 0, 5 do -- Test items
        local bouncy = TestItem.new()
        local pos = pickFromPickerList()
        bouncy:setPos(pos)
        bf:addItem(bouncy)
        logprint("added test at " .. tostring(pos))
    end
end
Little_Apple wrote:DnD: the REAL bitfighter levelgen documentation

Santiago ZAP wrote:bob doesn't make new maps, he makes new gamemodes
<<

tazinator

Posts: 351

Joined: Fri Jul 05, 2013 7:35 pm

Post Tue Apr 01, 2014 3:02 am

Re: coordinate picker help

thanks . u cam c in pleaides, ,mazeattacker
Play my new level! Two different teams fight over a nexus: One mainly defends while the other attacks! is fun
viewtopic.php?f=33&p=21002#p21002

Return to Levelgen Gallery

Who is online

Users browsing this forum: No registered users and 1 guest

cron