Posté le: 01/09/09 13:28 Sujet du message: [vJass] circleslide
Nom de la structure : circleside Créateur : Bantas, mais plein d'autres auparavant
Fonctions requises : Librairie TimerUtils par Vexorian Code :
Code:
library CircleSlide requires TimerUtils
//*********************************************************************
//Méthode principale :
//static method create takes unit whichUnit,
// real speed,
// real aroundX,
// real aroundY,
// real duration,
// real offset
// returns circleslide
//
//whichUnit est l'unité qui va tourner autour du point.
//speed est la vitesse linéaire de l'unité, en distance par seconde. Valeur positive pour tourner dans le sens trigonométrique, négative pour le sens horaire.
//aroundX et aroundY sont les coordonnées du point autour duquel l'unité va tourner
//duration est la durée du mouvement.
//offset est la vitesse à laquelle l'unité va s'éloigner du point. Valeur négative pour l'en approcher.
//
//*********************************************************************
//
//Getters :
//method getUnit takes nothing returns unit
//method getSpeed takes nothing returns real
//method getCenterX takes nothing returns real
//method getCenterY takes nothing returns real
//method getRemainingTime takes nothing returns real
//method getOffset takes nothing returns real
//
//Setters :
//method setUnit takes unit newUnit returns boolean
//method setSpeed takes real newSpeed returns boolean
//method setCenterX takes real newAroundX returns nothing
//method setCenterY takes real newAroundY returns nothing
//method setRemainingTime takes real newDuration returns boolean
//method setOffset takes real newOffset returns boolean
//Les méthodes renvoyant un booléen indiquent si l'opération n'a pas détruit la struct et donc arrêté le mouvement.
//
//*********************************************************************
globals
private constant real FLUID_VIS_PERIOD = 0.027
//Fluid-Visual Period. Ce temps séparera chacun
//des mouvements effectués de façon à ce que le
//résultat final paraisse fluide.
endglobals
struct circleslide
private unit whichUnit //Unité en mouvement
private timer whichTimer
private real speed //Vitesse linéaire de l'unité
private real aroundX //Coordonnées du centre du cercle
private real aroundY
private real duration //Temps restant
private real offset //L'unité s'éloigne du centre à cette vitesse chaque occurrence.
//Getters
method getUnit takes nothing returns unit
return this.whichUnit
endmethod
//Setters
method setUnit takes unit newUnit returns boolean
local boolean b = (whichUnit != null)
if (b) then
set this.whichUnit = newUnit
else
call this.destroy()
endif
return b
endmethod
method setSpeed takes real newSpeed returns boolean
local boolean b = (newSpeed == 0 and this.offset == 0)
set this.speed = newSpeed * FLUID_VIS_PERIOD
if (b) then
call this.destroy()
endif
return (not b)
endmethod
method setCenterX takes real newAroundX returns nothing
set this.aroundX = newAroundX
endmethod
method setCenterY takes real newAroundY returns nothing
set this.aroundY = newAroundY
endmethod
method setRemainingTime takes real newDuration returns boolean
local boolean b = (newDuration >= FLUID_VIS_PERIOD)
if (b) then
set this.duration = newDuration
else
call this.destroy()
endif
return b
endmethod
method setOffset takes real newOffset returns boolean
local boolean b = (this.speed == 0 and newOffset == 0)
set this.offset = newOffset * FLUID_VIS_PERIOD
if (b) then
call this.destroy()
endif
return (not b)
endmethod
private static method cycle takes nothing returns nothing
local circleslide this = GetTimerData(GetExpiredTimer())
//Calcul de la nouvelle position
local real dx = GetUnitX(this.whichUnit) - this.aroundX
local real dy = GetUnitY(this.whichUnit) - this.aroundY
local real distance = SquareRoot((dx * dx) + (dy * dy)) + this.offset //distance du centre
local real angle = Atan2(dy,dx) + Atan2(this.speed,distance)
local real x = this.aroundX + distance * Cos(angle)
local real y = this.aroundY + distance * Sin(angle)
//Réglage de la nouvelle position
call SetUnitX(this.whichUnit,x)
call SetUnitY(this.whichUnit,y)
//Fin du cycle ?
set this.duration = this.duration - FLUID_VIS_PERIOD
if (this.duration <= 0) then
call this.destroy()
endif
endmethod
static method create takes unit whichUnit, real speed, real aroundX, real aroundY, real duration, real offset returns circleslide
local circleslide this = 0
//Vérification que les paramètres sont corrects.
if (whichUnit == null) then
debug call BJDebugMsg("circleslide.create() : L'unité donnée n'existe pas. Le mouvement a été annulé. Merci de signaler ce problème au développeur.")
return 0
endif
if (duration < FLUID_VIS_PERIOD) then
debug call BJDebugMsg("circleslide.create() : La durée donnée est trop courte. Le mouvement a été annulé. Merci de signaler ce problème au développeur.")
return 0
endif
if (speed == 0 and offset == 0) then
debug call BJDebugMsg("circleslide.create() : La vitesse donnée est nulle. Le mouvement a été annulé.")
return 0
endif
//Setting struct
set this = circleslide.allocate()
set this.whichUnit = whichUnit
set this.whichTimer = NewTimer()
set this.speed = speed * FLUID_VIS_PERIOD
set this.aroundX = aroundX
set this.aroundY = aroundY
set this.duration = duration
set this.offset = offset * FLUID_VIS_PERIOD
Utilisation : Permet de faire tourner l'unité whichUnit autour du point de coordonnées aroundX; aroundY pendant un temps donné. Il est également possible de faire des spirales en réglant offset, qui est une valeur qui sera ajoutée à la distance à chaque tic. La vitesse donnée doit être une vitesse réelle, et non angulaire contrairement à la précédente version de la fonction (voir plus bas).
Copyright : Libre
Remarques : Doit remplacer mon ancienne fonction CircleMoveUnit, d'utilité similaire à son époque. La fonction en question peut sûrement aller au cimetière.
N'hésitez pas à lire les commentaires de la library pour en savoir plus.
Recquiert un éditeur compatible vJass, comme d'hab. _________________
Dernière édition par Bantas le 10/07/13 02:07; édité 2 fois
Merci pour ce systeme ( Il m'a permis d'apprendre les struct ).
Je post une version améliorée:
Secret:
Jass:
library CircleMouvement requires TimerUtils
//===========================================================================
// CIRCLE MOUVEMENT v 1.0 By wareditor
//===========================================================================
//
//METHOD
//call CircleMouvement.create(whichUnit, speed, Xaround, Yaround, duration, offset, remove)
//
//COMMENTARY
//Make Unit Circle around a Cord
//Thanks to Bantas for his CircleSlideUnit
//
//===========================================================================
// GLOBALS
//===========================================================================
globals
private constant real FLUID_VIS_PERIOD = 0.027
//Fluid-Visual Period. As the name tells,
//this is used to get fluid visuals when
//moving units for example. You should use
//distance/seconds, then multiply it by
//FLUID_VIS_PERIOD, in order to get the same
//speed even if you change the constant.
endglobals
unit whichUnit //Which unit is being moved ?
timer whichTimer
real speed //This is the real speed (not angular)
real Xaround //Coord of the location the unit spins around
real Yaround
real duration //Time left for the movement ( if d=0 then it will be infinite )
real offset //This value is added to the distance in each tick.
boolean remove//If true will remove the unit after the end
local thistype this = GetTimerData(GetExpiredTimer())
//The calculations
local real dx = GetUnitX(this.whichUnit) - this.Xaround
local real dy = GetUnitY(this.whichUnit) - this.Yaround
local real d = SquareRoot((dx * dx) + (dy * dy)) + this.offset //distance
local real a = Atan2(dy,dx) + (this.speed / d) //angle
local real x = this.Xaround + d * Cos(a)
local real y = this.Yaround + d * Sin(a)
//If the unit is null we stop the action
if(GetUnitTypeId(this.whichUnit) == 0)then
call this.destroy()
endif
//Checking if we need to end this
if( this.duration != 0 )then//If d=0 then it's infinite
set this.duration = this.duration - FLUID_VIS_PERIOD
if (this.duration <= 0) then
if(this.remove == true)then
call RemoveUnit(this.whichUnit)
endif
call this.destroy()
endif
endif
static method create takes unit whichUnit, real speed, real Xaround, real Yaround, real duration, real offset, boolean remove returns thistype
local thistype this
//If Unit = null
if (GetUnitTypeId(whichUnit) == 0) then //No null unit ( work even with ghost unit )
debug call BJDebugMsg("Warning: CircleMouvement has been given a null unit. Movement cancelled.")
return null
endif
//If Speed = 0
if(speed == 0)then
debug call BJDebugMsg("Warning: CircleMouvement has been given a null speed. Movement cancelled.")
return null
endif
//Setting struct
set this = thistype.allocate()
set this.whichUnit = whichUnit
set this.whichTimer = NewTimer()
set this.speed = speed
set this.Xaround = Xaround
set this.Yaround = Yaround
set this.duration = duration
set this.offset = offset
set this.remove = remove
//===========================================================================
// CIRCLE MOUVEMENT v 1.1 By wareditor
//===========================================================================
//
// METHOD :
// * call CircleMouvement.create(whichUnit, speed, Xaround, Yaround, duration, offset, remove)
//
// COMMENTARY :
// Make Unit Circle around a Cord
// Thanks to Bantas for his CircleSlideUnit
//
//===========================================================================
// Enjoy
//===========================================================================
globals
private integer LIST
private timer FREQ = CreateTimer()
private boolean START = false
private constant real FLUID_VIS_PERIOD = 0.027
//Fluid-Visual Period. As the name tells,
//this is used to get fluid visuals when
//moving units for example. You should use
//distance/seconds, then multiply it by
//FLUID_VIS_PERIOD, in order to get the same
//speed even if you change the constant.
endglobals
unit whichUnit //Which unit is being moved ?
timer whichTimer
real speed //This is the real speed (not angular)
real Xaround //Coord of the location the unit spins around
real Yaround
real radius
real duration //Time left for the movement ( if d=0 then it will be infinite )
real offset //This value is added to the distance in each tick.
boolean remove//If true will remove the unit after the end
local thistype this
local integer maxunit = EL_GetMaxUnit(LIST)
local integer i = 1
local real dx
local real dy
local real d
local real a
local real x
local real y
loop
exitwhen(i>maxunit)
set this = EL_GetUnitCD(LIST,i)
//The calculations
set dx = GetUnitX(this.whichUnit) - this.Xaround
set dy = GetUnitY(this.whichUnit) - this.Yaround
set d = this.radius + this.offset //distance
set a = Atan2(dy,dx) + (this.speed / d)//angle
set x = this.Xaround + d * Cos(a)
set y = this.Yaround + d * Sin(a)
set this.radius = d
//If the unit is null we stop the action
if(GetUnitTypeId(this.whichUnit) == 0)then
call this.destroy()
endif
//Checking if we need to end this
if( this.duration != 0 )then//If d=0 then it's infinite
set this.duration = this.duration - FLUID_VIS_PERIOD
if (this.duration <= 0) then
static method create takes unit whichUnit, real speed, real Xaround, real Yaround, real duration, real offset, boolean remove returns thistype
local thistype this
local real dx
local real dy
//If Unit = null
if 40;GetUnitTypeId40;whichUnit) == 0) then //No null unit ( work even with ghost unit )
debug call BJDebugMsg40;"Warning: CircleMouvement has been given a null unit. Movement cancelled.")
return null
endif
//If Speed = 0
if40;speed == 0)then
debug call BJDebugMsg40;"Warning: CircleMouvement has been given a null speed. Movement cancelled.")
return null
endif
//Setting struct
set this = thistype.allocate40;)
set this.whichUnit = whichUnit
set this.speed = speed
set this.Xaround = Xaround
set this.Yaround = Yaround
set dx = GetUnitX40;this.whichUnit) - this.Xaround
set dy = GetUnitY40;this.whichUnit) - this.Yaround
set this.radius = SquareRoot40;40;dx * dx) + 40;dy * dy))
set this.duration = duration
set this.offset = offset
set this.remove = remove
private function Init takes nothing returns nothing
set LIST = EL_NewList40;)
endfunction
endlibrary
La fameuse liste, qui est tres simple donc optimisable ( remplis de quelques fonctions inutiles... )
Secret:
Jass:
library EasyList
//===========================================================================
// EASY LIST v 1.0 By wareditor
//===========================================================================
//
// FUNCTIONS :
// * I'm lazy
//
// COMMENTARY :
// Could be a lot better
//
//===========================================================================
// Enjoy
//===========================================================================
function EL_AddUnit takes unit u, integer l returns boolean
if(GetUnitTypeId(u) == 0)then
debug call BJDebugMsg("Warning: EasyList has been given a null unit.")
return false
endif
if(EL_GetUnitList(u,"list")==0)then
set CURRENT_UNIT[l] = CURRENT_UNIT[l]+1
set UNIT[l][CURRENT_UNIT[l]] = u
return true
else
debug call BJDebugMsg("Warning: EasyList has been given a unit that is already in the list.")
return false
endif
endfunction
function EL_RemoveUnit takes integer l, integer i returns nothing
local integer s = i
loop
exitwhen(s>CURRENT_UNIT[l])
if(GetUnitTypeId(UNIT[l][s+1]) != 0) then
set UNIT[l][s] = UNIT[l][s+1]
endif
set s=s+1
endloop
set CURRENT_UNIT[l] = CURRENT_UNIT[l]-1
endfunction
function EL_SetCustomData takes integer l, integer i, integer CD returns nothing
set UNIT_CUSTOM_DATA[l][i]=CD
endfunction
function EL_NewList takes nothing returns integer
set CURRENT_LIST = CURRENT_LIST+1
return CURRENT_LIST
endfunction
Inscrit le: 23 Aoû 2007 Messages: 7143 Sujets: 147 Spécialité en worldedit: le troll, le flood, la vulgarité, mon coeur balance Médailles: 2 (En savoir plus...)
Posté le: 08/02/12 19:05 Sujet du message:
Euh non.
Je ne sais pas où vraiment commencer, mais ta list est vraiment tout sauf simple à utiliser, et je ne suis même pas certain qu'elle fonctionne correctement.
J'ai essayé de comprendre le code pendant de longues minutes (seriously), et j'ai du mal à suivre le fonctionnement interne, j'ai même laissé tombé.
Demande à Tirlititi ou Max si tu ne me crois pas.
Y'a plein de mauvais choix :
- utiliser un entier plutôt qu'une struct (même si c'est la même chose une fois convertit en jass), cela rend l'utilisation vraiment pas intuitive et error prone.
- des noms de paramètres vraiment pas explicites "i", "l" ...
- une utilisation de array 2D statiques qui limite énormément le nombre et le format des listes disponibles
- tu ne peux même pas détruire une liste une fois créée.
Maintenant UnitLL ne convient pas pour tout, mais j'ai clairement écrit dans quels cas c'est utile.
Certes il y a des pré-requis à son utilisation, à savoir :
- comprendre et savoir utiliser le mécanisme des listes non circulaire doublement chaînées, et sa transposition en vJass avec une struct.
Et aussi incroyable que cela puisse paraître, malgré le faible nombre lignes de code, cette liste reste globalement bien moins efficace que la mienne.
Il faudrait aussi te forcer à systématiquement utiliser une indentation correcte de ton code.
Incorrect :
Jass:
private function Init takes nothing returns nothing
set LIST = EL_NewList()
endfunction
globals
private unit array UNIT[10][50]
private integer array UNIT_CUSTOM_DATA[10][50]
if(GetUnitTypeId(u) == 0)then
debug call BJDebugMsg("Warning: EasyList has been given a null unit.")
endif
loop
exitwhen(i>CURRENT_UNIT[l])
if(u==UNIT[l][i])then
if(action=="list")then
return l
elseif(action=="pos")then
return i
endif
endif
set i=i+1
endloop
La chose à retenir est qu'à chaque fois que tu rentres dans un autre bloc de code, une tabulation est de rigueur.
Ca ne change rien au code en lui même, mais améliore grandement sa lisibilité, et donc sa maintenance et compréhension. _________________
Ok.
J'ai refait ma EasyList, je n'avais pas penser que des structs pouvait avoir de array >.<. Je pense que c'est mieux non ?
Secret:
Jass:
library CircleMouvement requires EasyList
//===========================================================================
// CIRCLE MOUVEMENT v 1.1 By wareditor
//===========================================================================
//
// METHOD :
// * call CircleMouvement.create(whichUnit, speed, Xaround, Yaround, duration, offset, remove)
//
// COMMENTARY :
// Make Unit Circle around a Cord
// Thanks to Bantas for his CircleSlideUnit
//
//===========================================================================
// Enjoy
//===========================================================================
globals
private EasyList LIST = 0
private timer FREQ = CreateTimer()
private boolean START = false
private constant real FLUID_VIS_PERIOD = 0.027
//Fluid-Visual Period. As the name tells,
//this is used to get fluid visuals when
//moving units for example. You should use
//distance/seconds, then multiply it by
//FLUID_VIS_PERIOD, in order to get the same
//speed even if you change the constant.
endglobals
unit whichUnit //Which unit is being moved ?
timer whichTimer
real speed //This is the real speed (not angular)
real Xaround //Coord of the location the unit spins around
real Yaround
real radius
real duration //Time left for the movement ( if d=0 then it will be infinite )
real offset //This value is added to the distance in each tick.
boolean remove//If true will remove the unit after the end
local real dx
local real dy
local real d
local real a
local real x
local real y
loop
exitwhen(i>LIST.Count)
set this = LIST.GetUnitCustomData(LIST.Unit[i])
//The calculations
set dx = GetUnitX(this.whichUnit) - this.Xaround
set dy = GetUnitY(this.whichUnit) - this.Yaround
set d = this.radius + this.offset //distance
set a = Atan2(dy,dx) + (this.speed / d)//angle
set x = this.Xaround + d * Cos(a)
set y = this.Yaround + d * Sin(a)
set this.radius = d
//If the unit is null we stop the action
if(GetUnitTypeId(this.whichUnit) == 0)then
call this.destroy()
endif
//Checking if we need to end this
if( this.duration != 0 )then//If d=0 then it's infinite
set this.duration = this.duration - FLUID_VIS_PERIOD
if (this.duration <= 0) then
static method create takes unit whichUnit, real speed, real Xaround, real Yaround, real duration, real offset, boolean remove returns thistype
local thistype this
local real dx
local real dy
//If Unit = null
if 40;GetUnitTypeId40;whichUnit) == 0) then //No null unit ( work even with ghost unit )
debug call BJDebugMsg40;"Warning: CircleMouvement has been given a null unit. Movement cancelled.")
return null
endif
//If Speed = 0
if40;speed == 0)then
debug call BJDebugMsg40;"Warning: CircleMouvement has been given a null speed. Movement cancelled.")
return null
endif
//Setting struct
set this = thistype.allocate40;)
set this.whichUnit = whichUnit
set this.speed = speed
set this.Xaround = Xaround
set this.Yaround = Yaround
set dx = GetUnitX40;this.whichUnit) - this.Xaround
set dy = GetUnitY40;this.whichUnit) - this.Yaround
set this.radius = SquareRoot40;40;dx * dx) + 40;dy * dy))
set this.duration = duration
set this.offset = offset
set this.remove = remove
if40;LIST == 0)then
set LIST = EasyList.create40;)
endif
call LIST.addUnit40;whichUnit)
call LIST.setCustomData40;whichUnit,this)
if40;START == false)then
set START = true
call TimerStart40;FREQ, FLUID_VIS_PERIOD, true, function CircleMouvement.cycle)
endif
//===========================================================================
// EASY LIST v 1.0 By wareditor
//===========================================================================
//
// METHODS :
//
// *.create()
// Create a New List where you can store units
// *.addUnit(whichUnit)
// Add a unit to the list
// *.removeUnit(whichUnit)
// Remove an unit form the list
// *.setCustomData(whichUnit,CustomData)
// Add a custom data ( integer ) to a stored unit
// *.GetCustomData(whichUnit)
// Return the Custom Data of an unit
// *.IsUnitInList(whichUnit)
// Return Boolean
// *.GetUnitPos(whichUnit)
// Return the postition ( integer ) of the unit in the list.
// *.clear()
// clear the list form all units
// *.destroy()
// destroy the list
//
// COMMENTARY :
// A easy list for lazy people
//
//===========================================================================
// Enjoy
//===========================================================================
unit array Unit[256]
integer array UnitCustomData[256]
integer Count = 0
method GetUnitPos takes unit u returns integer
local integer i = 1
loop
exitwhen(i>this.Count)
if(u==this.Unit[i])then
return i
endif
set i = i+1
endloop
return 0
endmethod
method GetUnitCustomData takes unit u returns integer
local integer pos = this.GetUnitPos(u)
return this.UnitCustomData[pos]
endmethod
method IsUnitInList takes unit u returns boolean
local integer i = 1
loop
exitwhen(i>this.Count)
if(u==this.Unit[i])then
return true
endif
set i = i+1
endloop
return false
endmethod
method addUnit takes unit u returns boolean
if(GetUnitTypeId(u) == 0)then
debug call BJDebugMsg("Warning: EasyList has been given a null unit.")
return false
endif
if(IsUnitInList(u) == true)then
debug call BJDebugMsg("Warning: EasyList has been given a unit that is already in the lsit.")
return false
endif
set this.Count=this.Count+1
set this.Unit[this.Count]=u
return true
endmethod
method removeUnit takes unit u returns boolean
local integer i
if40;GetUnitTypeId40;u) == 0)then
debug call BJDebugMsg40;"Warning: EasyList has been given a null unit.")
return false
endif
if40;this.IsUnitInList40;u) == false)then
debug call BJDebugMsg40;"Warning: EasyList has been given a unit that isn't in the lsit.")
return false
endif
set i = this.GetUnitPos
loop
exitwhen40;i>this.Count)
if40;GetUnitTypeId40;this.Unit[i+1])!=0)then
set this.Unit[i]=this.Unit[i+1]
endif
set i=i+1
endloop
set this.Count = this.Count - 1
return true
endmethod
method setCustomData takes unit u, integer data returns boolean
if40;GetUnitTypeId40;u) == 0)then
debug call BJDebugMsg40;"Warning: EasyList has been given a null unit.")
return false
endif
if40;this.IsUnitInList40;u) == false)then
debug call BJDebugMsg40;"Warning: EasyList has been given a unit that isn't in the lsit.")
return false
endif
set this.UnitCustomData[this.GetUnitPos40;u)]=data
return true
endmethod
method clear takes nothing returns nothing
local integer i = 1
loop
exitwhen40;i>Count)
set this.Unit[i] = null
set this.UnitCustomData[i] = 0
set i=i+1
endloop
set this.Count = 0
endmethod
method destroy takes nothing returns nothing
local integer i = 1
call this.clear40;)
call this.deallocate40;)
endmethod
endstruct
endlibrary
(Je fais des effort pour les tabulations mais defois j'oublie ._.) _________________
Inscrit le: 23 Aoû 2007 Messages: 7143 Sujets: 147 Spécialité en worldedit: le troll, le flood, la vulgarité, mon coeur balance Médailles: 2 (En savoir plus...)
Posté le: 09/02/12 19:46 Sujet du message:
C'est mieux, mais je n'irais pas jusqu'à dire que c'est bien.
Ce n'est pas un concours de e-penis à celui qui a la plus grosse, mais sérieusement tu peux pas vraiment mieux faire que UnitLL, sauf pour des cas particuliers, mais pour les cas particuliers on peut très bien coder soit même le "système".
Prenons l'exemple d'un slide avec des patrols de mob, pour les sliders on peut très bien et facilement utiliser une simple stack avec pour implémentation une unit array, et même pour les mobs on peut utiliser une simple stack (pile).
Certaines de tes method qui devraient avoir une complexité algorithmique de O(1) sont en O(N), (wikipedia is your friend).
C'est chiant de devoir choisir le nombre max d'unités qu'une liste peut contenir, le jass comme bien des langages haut niveaux, gère la taille des tableaux automatiquement, ils ne sont pas statiques.
D'ailleurs en définissant une limite de 256 unités, tu n'autorises à créer que 31 listes simultanément : (8190 / 256)
PS : Pour les tabulations ça doit devenir automatique, tu dois le faire sans réfléchir. _________________
Je ne veux pas faire mieux que ton UnitLL, je veux faire plus simple. Enfait je ne vois pas comment il fonctionne - ta démo me semble tellement complexe pour l'effet donné... Un code peux sembler simple a comprendre pour son créateur mais plus dur pour autres.
Je vais voir ton histoire de complexité. ( ici ? )
Inscrit le: 23 Aoû 2007 Messages: 7143 Sujets: 147 Spécialité en worldedit: le troll, le flood, la vulgarité, mon coeur balance Médailles: 2 (En savoir plus...)
Posté le: 09/02/12 20:50 Sujet du message:
Wareditor a écrit:
Je ne veux pas faire mieux que ton UnitLL, je veux faire plus simple.
Et pourtant UnitLL est simple d'utilisation.
Mais si tu veux me faire dire qu'UnitLL n'est pas utilisable si on ne maîtrise pas les pré-requis, alors oui, mais c'est comme tout ...
Ca vaut vraiment le coup de les apprendre car sont bien souvent utiles.
Citation:
Enfait je ne vois pas comment il fonctionne - ta démo me semble tellement complexe pour l'effet donné... Un code peux sembler simple a comprendre pour son créateur mais plus dur pour autres.
Comme je l'ai dit y'a des pré-requis, dans la démo j'utilise aussi une stack dynamique codé "à la main", avec pour implémentation une linked list simplement chaînée non circulaire (pour les effets).
Certes c'est impressionnant pour les néophytes mais il vaut mieux maîtriser de telles structures de données.
Citation:
Je vais voir ton histoire de complexité. ( ici ? )
Ce qui a de bien avec wikipedia c'est que bien souvent le même article est disponible en plusieurs langues (même si la qualité tend à baisser quand ce n'est pas en anglais)
Citation:
Ok j'ai supprimée la limite
Pardon ?
PS :
Tu es en train de faire les mêmes erreurs que moi, tu codes un truc jusque parce que tu trouves ca cool, tu n'en n'as pas réelle utilité.
Le procédé devrait être l'inverse, puisque tu as besoin d'un système tu le codes.
J'ai codé UnitLL pour diverses raisons :
- Il n'y a pas de moyen "sexy" (flemme de développer plus) de loop sur un group que l'on garde dans le temps.
- l'absence de return value sur les function Group{add/remove}Unit m'a toujours fait chier.
- pas moyen de savoir le nombres d'unités présentes dans un group sans devoir loop sur tout le groupe et incrémenter une variable entière. _________________
Inscrit le: 14 Avr 2011 Messages: 1846 Sujets: 119 Spécialité en worldedit: fonctions paramétriques, équation de mouvement.
Posté le: 03/07/12 21:44 Sujet du message:
j'hésite à envoyer la library circle que j'ai fait à ma sauce :p xD (nan j'dec la mienne ne fait que des cercles basiques sans possibilité de remove au bout d'un certain temps) _________________
22:27:43<Seiraw> Bah y a deux genre de personnes
22:27:57<Seiraw> les soumis et les soumises
Je reviens plus ou moins par hasard sur ce thread des années après et constate que certains choix que j'ai fait en écrivant ce machin sont.. bizzarres. Peut-être approprié si vous êtes dans une optique du JASS, mais il serait sûrement plus propre de :
1. Ajouter d'autres méthodes pour changer les paramètres du déplacement en cours et mettre les membres en privé au lieu de juste refiler la structure sans mode d'emploi. Au moins le timer. Modifier la vitesse à 0 reviendrait à stopper tout le processus.
2. Rendre FLUID_VIS_PERIOD publique, ce serait peut être pratique. Il me semble que c'était une globale publique sur mes anciennes map.
3. Plus de méthodes. Tout caler en méthode. Quoique pour du JASS..
Après si on veut s'amuser on pourrait aussi rajouter un appel supplémentaire de déclencheur sur le cycle, si l'utilisateur veut modifier la vitesse ou quoi que ce soit. Pas que ce soit très utile en 2013 mais bon.
EDIT: Je me demande si le script marche seulement, étant donné cette ligne :
Jass:
local real a = Atan2(dy,dx) + (f.speed / d)
Le (f.speed/d) devrait être une tangeante, il manque donc une arctangeante pour récupérer un angle. J'ai de vagues souvenirs de bugs où l'unité se téléportait tout autour du cercle, ça ne m'étonnerait pas que ça vienne de là. Un Atan2(f.speed,d) serait probablement plus approprié. _________________
Toutes les heures sont au format GMT + 1 Heure Aller à la page 1, 2Suivante
Page 1 sur 2
Vous ne pouvez pas poster de nouveaux sujets dans ce forum Vous ne pouvez pas répondre aux sujets dans ce forum Vous ne pouvez pas éditer vos messages dans ce forum Vous ne pouvez pas supprimer vos messages dans ce forum Vous ne pouvez pas voter dans les sondages de ce forum