- Joined
- Dec 4, 2007
- Messages
- 76
Okay, so for those of you familiar with the game "Tron" you will know that a tail follows you as you go, and you use arrow keys to manuever. Well i'm trying to remake this on wc3, but im having a problem with turns.
In the game tron when you turn, your tail should have a sharp turn to it like an L or something. However, in my game I can't get a sharp turn like that, and that's what I need help with. When I turn my tail is like an L but with a tile misplaced to the side. Kinda like...
|
-—
Its a crude drawing but you get the gist of things. There is one misplaced tile and I dont know how to fix it. Here is one of the triggers, maybe you can help.
In the game tron when you turn, your tail should have a sharp turn to it like an L or something. However, in my game I can't get a sharp turn like that, and that's what I need help with. When I turn my tail is like an L but with a tile misplaced to the side. Kinda like...
|
-—
Its a crude drawing but you get the gist of things. There is one misplaced tile and I dont know how to fix it. Here is one of the triggers, maybe you can help.
-
RedKeyLeft
-
Events
- Player - Player 1 (Red) Presses the Left Arrow key
-
Conditions
- Right[1] Equal to False
-
Actions
- Set Left[1] = True
- Set Right[1] = False
- Set Down[1] = False
- Set Up[1] = False
- Unit - Make Tails1[1] face 180.00 over 0.00 seconds
-
Events
JASS:
//TESH.scrollpos=0
//TESH.alwaysfold=0
//function PolarProjectionBJ takes location source, real dist, real angle returns location
// local real x = GetLocationX(source) + dist * Cos(angle * bj_DEGTORAD)
// local real y = GetLocationY(source) + dist * Sin(angle * bj_DEGTORAD)
// return Location(x, y)
//endfunction
//the above is a copy of PolarProjectionBJ I put it there to show you how it works
constant function Speed takes nothing returns real //Just modify the value in the 'return' to make it go faster/slower
return 10.00
endfunction
function Trig_MoveUnits_Actions takes nothing returns nothing
// local location unitspot //Locations are slow
local real facing
// local location newspot
local group ArenaUnits = CreateGroup() //Replaced with natives
local unit u
local real MoveX
local real MoveY
call GroupEnumUnitsInRect(ArenaUnits, gg_rct_CamView, null) //Some more natives used to replace the previous group method
loop
exitwhen CountUnitsInGroup( ArenaUnits ) <= 0
set u = GroupPickRandomUnit( ArenaUnits )
set facing = GetUnitFacing( u )
set MoveX = GetUnitX(u) + Speed() * Cos(facing * bj_DEGTORAD) //the bj_DEGTORAD is just a constant, so its ok to use
set MoveY = GetUnitY(u) + Speed() * Sin(facing * bj_DEGTORAD) //This is exactly what polarbj does except without the locations!
call SetUnitX(u,MoveX) //This is a super fast native which doesn't cancel orders!!!
call SetUnitY(u,MoveY)
call GroupRemoveUnit( ArenaUnits, u )
call IssueImmediateOrder(u,"stop") //Effectivley cancels orders! (Otherwise unit goes in circles)
endloop
if not (ArenaUnits == null) then //This stops it from trying to destroy the group if theres nothing in it
call DestroyGroup( ArenaUnits )
endif
set ArenaUnits = null //Your only suppose to null it AFTER you destroy it!!!!!
set u = null
endfunction
//===========================================================================
function InitTrig_MoveUnits takes nothing returns nothing
set gg_trg_MoveUnits = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_MoveUnits, 0.02 )
call TriggerAddAction( gg_trg_MoveUnits, function Trig_MoveUnits_Actions )
endfunction