1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
' It's all a bit rolly
'
Strict
Import noddybox.vector
Import noddybox.bitmapfont
' Includes
'
Include "types.bmx"
' Included binaries
'
Incbin "GFX/font.bmf"
' Initialise graphics
'
SetGraphicsDriver GLMax2DDriver()
Graphics 800,600,32,60
'HideMouse
SetBlend(ALPHABLEND)
' Globals
'
Global font:TBitmapFont=TBitmapFont.Load("incbin::GFX/font.bmf",0)
' Consts
'
' Test code
'
Global main_mass:TMass=New TMass
Global mass:TList=CreateList()
Global star:TList=CreateList()
Global cx:Int=GraphicsWidth()/2
Global cy:Int=GraphicsHeight()/2
main_mass.x=cx'/2
main_mass.y=cy
main_mass.friend=False
main_mass.g=100
main_mass.b=100
main_mass.inverse=True
For Local r:Int=0 Until 1000
Local s:TPoint=New TPoint
Local d:Float
Local a:Float
s=New TPoint
d=Rnd(50,100)
'a=Rnd(0,360)
a=Rand(0,3)*90
s.x=main_mass.x+d*Sin(a)
s.y=main_mass.y+d*Cos(a)
s.v.x=Sin(a+90)/(d/30)
s.v.y=Cos(a+90)/(d/30)
star.AddLast(s)
Next
mass.AddLast(main_mass)
While Not KeyHit(KEY_ESCAPE)
Cls
Local dead:Int=0
Local lost:Int=0
For Local m:TMass=EachIn mass
For Local s:TPoint=EachIn star
s.Attract(m)
Next
Next
For Local m:TMass=EachIn mass
m.MoveAndDraw()
Next
For Local s:TPoint=EachIn star
s.MoveAndDraw()
If s.dead
dead:+1
ElseIf s.lost
lost:+1
EndIf
Next
font.Draw("PARTICLES",0,0)
font.DrawColoured(star.Count()-dead-lost,font.TextWidth("PARTICLES")+10,0,255,255,0)
font.Draw("CAPTURED",200,0)
font.DrawColoured(dead,font.TextWidth("CAPTURED")+210,0,255,0,255)
font.Draw("LOST",400,0)
font.DrawColoured(lost,font.TextWidth("LOST")+410,0,255,0,0)
If MouseHit(1)
Local m:TMass=New TMass
m.x=MouseX()
m.y=MouseY()
mass.AddLast(m)
EndIf
FlushMem
Flip
Wend
' Globals
'
Rem
Global player:TBall=New TBall
player.r=255
player.g=255
player.b=255
Global balls:TList=CreateList()
balls.AddLast(player)
For Local f:Int=0 To 10
balls.AddLast(New TBall)
Next
While Not KeyHit(KEY_ESCAPE)
Cls
If KeyHit(KEY_MOUSELEFT)
player.v.x=MouseX()-player.x
player.v.y=MouseY()-player.y
player.v.Normalise()
player.v.Scale(2)
EndIf
For Local b1:TBall=EachIn balls
For Local b2:TBall=EachIn balls
If b1<>b2
b1.Collide(b2)
EndIf
Next
Next
For Local b1:TBall=EachIn balls
b1.MoveAndDraw()
Next
FlushMem
Flip
Wend
EndRem
EndGraphics
End
|