Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 represention of light emitting objects moving in 2d space
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Homer_simpson




PostPosted: Sun Dec 13, 2009 8:13 pm   Post subject: represention of light emitting objects moving in 2d space

objects moving near the speed of light but speed of light does not increase. The lighter the color the older the emission.
Quote:
View.Set ("graphics:1000;600,offscreenonly")
for clr : 1 .. 100
RGB.SetColor (clr + 100, (clr + 50) * 2, (clr + 50) * 2, (clr + 50) * 2)
end for
var scale := 10
const mxm := 100
const renewal := 50
const SOL := 1.5
const freqlength := 30

type Emitter :
record
x, y, vx, vy : real
xx : array 1 .. mxm of real
yy : array 1 .. mxm of real
rr : array 1 .. mxm of real
i : int
end record



color (white)
colorback (black)
cls



proc initializeEmitter (var e : Emitter, x, y, vangle, vmag : real)
e.x := x
e.y := y
e.vx := cosd (vangle) * vmag
e.vy := sind (vangle) * vmag
for i : 1 .. mxm
e.xx (i) := e.x
e.yy (i) := e.y
e.rr (i) := 10
end for
e.i := 1
end initializeEmitter





proc drawEmitter (e : Emitter, c1, c2 : int)
for i : 1 .. mxm
drawoval (round (e.xx (i) / scale) + (maxx div 2), round (e.yy (i) / scale) + (maxy div 2), round (e.rr (i) / scale), round (e.rr (i) / scale), (((round (e.rr (i) / scale) div freqlength)
mod (c2 - c1))) + c1)
end for
drawfilloval (round (e.x / scale) + (maxx div 2), round (e.y / scale) + (maxy div 2), 5, 5, white)
end drawEmitter

proc moveEmitter (var e : Emitter)
e.x += e.vx
e.y += e.vy
e.i += 1
if e.i >= mxm * renewal then
e.i := 1
end if
e.xx (1 + (e.i div renewal)) := e.x
e.yy (1 + (e.i div renewal)) := e.y
e.rr (1 + (e.i div renewal)) := 10
for i : 1 .. mxm
e.rr (i) += SOL
end for

end moveEmitter



var e1, e2, e3 : Emitter
initializeEmitter (e1, 500, 0, 20, .8)
initializeEmitter (e2, -2000, 0, 200, 1)
initializeEmitter (e3, -500, 0, 160, 1.3)

loop
moveEmitter (e1)
moveEmitter (e2)
moveEmitter (e3)
drawEmitter (e1, 16, 31)
drawEmitter (e2, 16, 31)
drawEmitter (e3, 16, 31)

View.Update
%cls
end loop


Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: