Jump to content



Photo

Circles B1.2


  • Please log in to reply
5 replies to this topic

#1 Tchernoben

Tchernoben

    Casio Fan

  • Members
  • PipPip
  • 42 posts
  • Location:Nice
  • Interests:Calculators, Pc, mangas, warhammer.

  • Calculators:
    Classpad 300
    Ti 89 Titanium

Posted 21 January 2006 - 05:48 PM

Hello, it's again me :)

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

#2 Kilburn

Kilburn

    Casio Technician

  • Members
  • PipPipPipPipPipPip
  • 491 posts
  • Gender:Male
  • Location:France
  • Interests:Blah

  • Calculators:
    FX-7500 G
    ClassPad 300

Posted 21 January 2006 - 07:58 PM

As I don't have my ClassPad now, I can't test... but what is the problem? What doesn't work?

#3 -Tom-

-Tom-

    Casio Freak

  • Members
  • PipPipPipPip
  • 104 posts
  • Location:Poland
  • Interests:Tides, Celestial Navigation, Deadreckoning

  • Calculators:
    Cla$$pad 300

Posted 21 January 2006 - 08:09 PM

At my CP it working fine. Lua 0.8C

#4 Tchernoben

Tchernoben

    Casio Fan

  • Members
  • PipPip
  • 42 posts
  • Location:Nice
  • Interests:Calculators, Pc, mangas, warhammer.

  • Calculators:
    Classpad 300
    Ti 89 Titanium

Posted 21 January 2006 - 11:20 PM

Well my current version is 0.72, where should I find an update ?

#5 -Tom-

-Tom-

    Casio Freak

  • Members
  • PipPipPipPip
  • 104 posts
  • Location:Poland
  • Interests:Tides, Celestial Navigation, Deadreckoning

  • Calculators:
    Cla$$pad 300

Posted 22 January 2006 - 09:07 AM

Here is the link

#6 Tchernoben

Tchernoben

    Casio Fan

  • Members
  • PipPip
  • 42 posts
  • Location:Nice
  • Interests:Calculators, Pc, mangas, warhammer.

  • Calculators:
    Classpad 300
    Ti 89 Titanium

Posted 22 January 2006 - 01:32 PM

Well It work perfectly now ^^
Thank you so much :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users