File: sliceanimation.kbs

package info (click to toggle)
basic256 2.0.99.10-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,888 kB
  • sloc: cpp: 17,185; yacc: 4,025; lex: 1,466; java: 1,091; sh: 39; xml: 33; makefile: 20
file content (57 lines) | stat: -rw-r--r-- 1,115 bytes parent folder | download | duplicates (2)
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
# sliceanimation.kbs
# 2010-05-08 j.m.reneau
# 2016-09-08 j.m.reneau updated for 2.0

# demonstration program of getslice function
# and putslice statements.

# easier accomplished with sprites because you do not
# have to slice the under image and then re draw it

fastgraphics

# capture slice of red foreground and clear background
clg 
color red
gosub randomdraw
refresh
slice = getslice(100,100,100,100)

# draw a screen of yellow and black to
# draw slice onto
color yellow
rect 0,0,300,300
color black
gosub randomdraw
refresh

# initial place and direction
x = 0
dx = rand * 3 + 1
y = 0
dy = rand * 3 + 1

while true
   # get new loction to put slise at
   x = x + dx
   if x < 1 or x > 200 then dx = dx * -1
   y = y + dy
   if y < 1 or y > 200 then dy = dy * -1
   # get whet is there before putting slice
   original = getslice(x,y,100,100)
   putslice x,y,slice[]
   refresh
   # change it back to what it was before the slice
   putslice x,y,original[]
end while
end

randomdraw:
# crap on the screen for example
for t = 1 to 100
   line rand * 300, rand * 300, rand * 300, rand * 300
next t
return