Login Register
Frontpage Code library Pastebin

Ascii-metapallot

Author: KilledWhale
Added: 9.4.2011 21:20
Edited: 15.4.2011 22:19
Category: Efektit

Description

Metapallot toteutettuna @-merkeillä.

Code

Select all
 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
// Ascii metaballs made with CoolBasic

SCREEN 400, 400
	
sw = ScreenWidth()
sh = ScreenHeight()
	
w = sw / 10
h = sh / 10
	
Const BALLS = 3
	
Type ball
	Field x
	Field y
	Field r
	Field mod1 As Float
	Field mod2 As Float
EndType
	
For i = 1 To BALLS
	b.ball = New(ball)
	b\x = Rand(w)
	b\y = Rand(h)
	b\r = 35 + Rand(15)
	b\mod1 = 1.5 - Rnd(1)
	b\mod2 = 1.5 - Rnd(1)
Next i

Repeat
	For x = 0 To w
		For y = 0 To h
			n# = 0.0
			For b.ball = Each ball
				xx = x - b\x
				yy = y - b\y
				n# = n# + b\r / (((xx * xx) + (yy * yy)) * 1.1)
				
				b\x = (w Shr 1) + (Sin(b\mod1 * (Timer() / 10)) * ((w - 10) Shr 1))
				b\y = (h Shr 1) + (Cos(b\mod2 * (Timer() / 10)) * ((h - 10) Shr 1))
			Next b
			
			If n# < 0 Then 
				n# = 0
			ElseIf n# > 1 Then
				n# = 1
			EndIf

			Color 0, n * 255, 0
			Text x * 10, y * 10, "@"
		Next y
	Next x
	
	SetWindow "Ascii meatballs - " + FPS()
	DrawScreen OFF
Forever

Comments

#27 Sent by: skorpioni_cb, 5.1.2012 10:05

Wow, tuo oli HIENO

Leave a comment

You must be logged in to comment.