This time I have a question, the code below don't work and I don't know why...
Could opne of you could help me ?
-- Circles b1.2 Tchernoben 2005
-- Merci a Julien pour son aide sur le Lua
-- Remerciment sp?cial a Frankinstain pour son aide et son support
-- vous pouvez modifier ce code comme bon vous semble tant que vous ne pretendez pas en etre l'auteur
-- la variable max sert a definir le nombre de cercle
-- la variable tolerance est le rayon moins un, elle sert a eviter au cercle de sortir du cadre
-- Requires
require("draw")
showgraph()
keypad(0)
fullscreen(1)
-- functions needed
function arrondi( x)
return math.floor( 10*x) / 10
end
function randuo()
A = math.random ( 0,1)
B = math.random ()
if A == 0 then A = -B else A = B
end
return arrondi( A)
end
-- Init vars
BAS = 225
HAUT = 0
DROITE = 158
GAUCHE = 0
tolerance = 11
max = 4
cercle = {}
for a=1,max do
cercle[a] = { math.random( GAUCHE+tolerance, DROITE-tolerance), math.random( HAUT+tolerance, BAS-tolerance), math.random( 3, ( tolerance-1)), randuo(), randuo()}
end
-- Body
repeat
for i=1, max do
cercle[i][1] = cercle[i][1] + cercle [i][4]
cercle[i][2] = cercle[i][2] + cercle [i][5]
end
-- test de sequence generique
for i=1, (max-1) do
for j=(i+1), max do
if ((( cercle[j][1] - cercle[i][1] )^2) + (( cercle[j][2] - cercle[i][2])^2) <= (( cercle[j][3] + cercle[i][3])^2)) then
cercle[i][4], cercle[i][5] = cercle[i][5], cercle[j][4]
end
end
end
-- fin du test de sequence
-- test decollision paroi
for i=1, max do
if (( cercle[i][1] + cercle[i][3]) >= DROITE) or (( cercle[i][1] - cercle[i][3]) <= GAUCHE) then
cercle[i][4] = - ( cercle[i][4])
end
if (( cercle[i][2] + cercle[i][3]) >= BAS) or (( cercle[i][2] - cercle[i][3]) <= HAUT) then
cercle[i][5] = - ( cercle[i][5])
end
end
-- fin des test de colision paroi
draw.clear()
draw.onbuffer(1)
for i=1, max do
draw.circle( cercle[i][1], cercle[i][2], cercle[i][3], 1,1,1)
end
draw.update()
until testkey( K_EXE)This program draw a number (max) of circles and move them on the screen.
I'll upload the previous version (working that one) soon



