Escolar Documentos
Profissional Documentos
Cultura Documentos
Mouse.ButtonChoose ("multibutton")
const *MAXX := "max"
const *MAXY := "max"
const *MAXNUMCOLOUR := 64
const
const
const
const
*Math_2PI := 2 * Math.PI
*Math_PI2 := Math.PI / 2
*Math_PI4 := Math.PI / 4
*Math_3PI4 := Math.PI * 3 / 4
const
const
const
const
*OPTION := 1
*LIFE := 20
*FRAMETIME := 0
*SPAWNRATE := 400
*electroncolour := ELECTRONCOLOUR
*shellradius : int := SHELLRADIUS
*electronsize : int := ELECTRONSIZE
*atomsize : int := ATOMSIZE %not used
*wall : int := WALL %0 means white wall, 1 means black wall
e)))
else
loc.x := MidScrX () + round (0.4 * seed1 * cos (angle))
loc.y := MidScrY () + round (0.66 * (-3 * shellradius + seed1 * sin (ang
le)))
end if
result loc
end pLocation2
fcn Location (x, y, b : int) : Int2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%derp
case orbital of
label 0 :
result sLocation1 (x, y, b)
label 1 :
result sLocation2 (x, y, b)
label 2 :
result pLocation1 (x, y, b)
label 3 :
result pLocation2 (x, y, b)
label 4 :
result sLocation3 (x, y, b)
end case
end Location
fcn * Move (obj : Property) : Int2
result obj.loc
end Move
fcn * Size (obj : Property) : Int2
var out : Int2
out.x := electronsize
out.y := electronsize
result out
end Size
fcn * Colour (obj : Property, life : int) : int
var ratio, ratio2 : real
if wall = 0 then
ratio := 0.5 + 0.5 * obj.t / life
case electroncolour of
label 0 :
result RGB.AddColor (ratio, 0, 0)
label 1 :
result RGB.AddColor (0, ratio, 0)
label 2 :
result RGB.AddColor (0, 0, ratio)
end case
elsif wall = 1 then
ratio := 1 - obj.t / life
ratio2 := ratio / 2
case electroncolour of
label 0 :
result RGB.AddColor (ratio, ratio2, ratio2)
label 1 :
result RGB.AddColor (ratio2, ratio, ratio2)
label 2 :
result RGB.AddColor (ratio2, ratio2, ratio)
end case
end if
end Colour
/*
var elecol : array 0 .. 1 of array
lours of electrons
%var x,y,b:int
proc CreateColours ()
for i : 0 .. MAXNUMCOLOUR
elecol (0) (0) (i) := RGB.AddColor
elecol (0) (1) (i) := RGB.AddColor
elecol (0) (2) (i) := RGB.AddColor
elecol (1) (0) (i) := RGB.AddColor
elecol (1) (1) (i) := RGB.AddColor
elecol (1) (2) (i) := RGB.AddColor
end for
end CreateColours
%%%%%%%%%%%%%%%%%%%%%%%%%%%
var particle :
record
prop :
last :
next :
end record
var head, tail
or deleted
var n : int :=
collection of
Property
^particle
^particle
: ^particle %head is the "first" particle but is never drawn
0 %num of particles
case shape of
label 0 :
drawfilloval (x_0, y_0, r_x, r_y, col)
label :
end case
end if
pt -> prop.loc := coor
pt -> prop.t += 1
case option of
label 0 :
if pt -> prop.t > 0 then
temp := pt -> last
Delete (pt)
pt := temp
end if
label 1 :
if pt -> prop.t > life then
temp := pt -> last
Delete (pt)
pt := temp
end if
end case
end loop
end Frame
fcn Flag (x, y, b : int) : boolean
%how to tell if user wants to quit ma
in loop; true if quit
if x ** 2 + y ** 2 < 100 and b not= 0 then
result true
end if
result false
end Flag
proc Initialize ()
new particle, head
head -> next := nil
tail := head
end Initialize
proc GetParameters ()
put "x resolution"
get maxscrx
put "y resolution"
get maxscry
put "shellradius"
get shellradius
put "electronsize"
get electronsize
put "life"
get life
put "frametime"
get frametime
put "spawnrate"
get spawnrate
end GetParameters
proc Background ()
if wall = 1 then
drawfillbox (0, 0, maxx, maxy, 7)
end if
end Background
proc Main (fcn Location (x, y, b : int) : Int2, fcn Move (obj : Property) :
Int2, fcn Size (obj : Property) : Int2, fcn Colour (obj : Property, lifearg : in
t) : int)
Initialize ()
GetParameters ()
cls
setscreen ("graphics:" + maxscrx + ";" + maxscry)
var xo, yo, bo, x, y, b : int
var chars : array char of boolean
Background ()
View.Set ("offscreenonly")
mousewhere (xo, yo, bo)
loop
mousewhere (x, y, b)
Input_KeyDown (chars)
if Flag (x, y, b) then
exit
end if
if option = 1 then
Background ()
end if
User (chars, xo, yo, bo, x, y, b, Location)
Frame (Move, Size, Colour)
View.Update
if option = 1 then
cls
end if
xo := x
yo := y
bo := b
end loop
View.Set ("nooffscreenonly")
end Main
end SimpleEngine
var pt : ^SimpleEngine
new SimpleEngine, pt
var garbage : string
%CreateColours ()
loop
pt -> Main (Location, Move, Size, Colour)
cls
put "continue?"
get garbage
if garbage = "no" then
exit
end if
cls
end loop