回 帖 发 新 帖 刷新版面

主题:淡入淡出的原程序!

PALETTE是调色板语句
调色板就和画家的一样,改变红、绿、蓝的配比,就能获得千变万化的颜色!
PALETTE 颜色号, 65536 * 红 + 256 * 绿 + 蓝
在screen 12的显示模式下能同屏显示16中颜色,从0到15号,系统默认0号是黑色,实际上我们可以自己改成需要的颜色,可以得到64*64*64中颜色,不过,在screen12模式下只能同屏显示16色,要同屏显示真彩色,就要用到vesa编程的资料,有意者请向冷石咨询!
相关知识连接
http://www.herosoft.com/accessory/jb3.php

PALETTE 颜色号, 65536 * 红 + 256 * 绿 + 蓝(65536和256都是固定的这个和位有关,换成16进制大家能看得更懂 &hffff*红+&Hff*绿+蓝)
例如:设置调色板

    PALETTE 5, 65536 * 55+ 256 * 44+ 32
就可以把5号颜色改成别的
这个语句非常有用,
有时候要用淡入淡出的效果,用FOR循环就搞定了!  
思路:把任意一个颜色号的红,绿、蓝直从0不断变化到最大,从最大到0就可以实现这个效果了!
SCREEN 12   '设置为12号图形模式
COLOR 14    '用14号颜色显示--文字 我爱你,qb   
LOCATE 15, 18: PRINT "I Love You !!!  Quick Basic 4.5 @_@"
FOR i = 0 TO 63
    PALETTE 14, &HFFFF * i + 256 * i + i   '从0改变14号颜色到最大63
    SOUND 500 + i * 15, 1 '发声提示,在这里,它还有延时的作用,让改变的颜色停留片刻
NEXT i
SOUND 500 + i * 15, 5
FOR i = 63 TO 1 STEP -1
    PALETTE 14, &HFFFF * i + 256 * i + i
    SOUND 500 + i * 15, 1
NEXT i
'最后用15号颜色显示文字结束
COLOR 15
LOCATE 15, 18: PRINT "The end"

回复列表 (共4个回复)

沙发

很有用啊
这样BAS的图象效果会好很多

板凳

秋水做的就是好啊,能不能逐句解释一下啊,好多语句都不懂啊#17

3 楼

我已经改了,如果还有疑问,请讲!

4 楼

这个是我找到的一个动画程序
DEFLNG A-Z
'3d matrix rotation and pseudo-morph demo by Toshihiro Horie
'http://www.ocf.berkeley.edu/~horie/project.html
'I don't quite understand 3D matrix transformations
'but it seems to work.  Have fun with BASIC!
CONST pi! = 3.1415927#
DIM cosine(360), sine(360)
DIM P(1 TO 3)
DIM R(1 TO 3, 1 TO 3)
DIM ANG(1 TO 3)
k = 256
deg2rad! = pi! / 180

FOR A = 0 TO 359
    cosine(A) = INT(.5 + COS(A * deg2rad!) * k)
    sine(A) = INT(.5 + SIN(A * deg2rad!) * k)
NEXT

ww = 1: vv = 0: SCREEN 9, , ww, vv
FOR zrot = 0 TO 359 STEP 2
FOR yrot = 0 TO 359 STEP 15
FOR xrot = 0 TO 359 STEP 60
    ANG(1) = xrot
    ANG(2) = yrot
    ANG(3) = zrot
    X = xrot \ 10: Y = ABS(sine(xrot)) \ 64: z = 6
    ca = cosine(ANG(1)): cb = cosine(ANG(2)): cc = cosine(ANG(3))
    sa = sine(ANG(1)): sb = sine(ANG(2)): ac = sine(ANG(3))
    'ROTATION MATRIX
    cacc = ca * cc
    casc = ca * sc
    R(1, 1) = cb * cc
    R(2, 1) = sb * cc + casc
    R(3, 1) = ca * sb - sasc
    R(1, 2) = cb * sc
    R(2, 2) = sa * sc + cacc
    R(3, 2) = ca * sb * sc - cacc
    R(1, 3) = -sb
    R(2, 3) = sa * cb
    R(3, 3) = ca * cb
    'CALCULATE ROTATED X,Y,Z
    FOR G = 1 TO 3
        P(G) = X * R(1, G) + Y * R(2, G) + z * R(3, G)
    NEXT
    'PRINT P(1) \ k, P(2) \ k, P(3) \ k

    'PROJECT TO 2D SCREEN - from Rich Geldreich's 3DEXP.BAS
    xx = P(1) \ k
    yy = P(2) \ k
    zz = P(3) \ k
    Mypos = 100: Spos = 85
    C1 = k
    S1 = 0
        xone = (xx * C1) \ 1024
        Y1 = yy
        X1 = xone
        Zn = xone \ k
        IF Zn = Mypos THEN GOTO skip:
      IF (Mypos - Zn) < 15 THEN
            Xn(R) = -1: Yn(R) = 0: Zn = 0
      ELSE
            'Put the point into perspective...
            v = (1330 * (Spos - Zn)) \ (Mypos - Zn)
            Xn = 320 + X1 + (-X1 * v) \ 1330
            Yn = 175 + (8 * (Y1 + (-Y1 * v) \ 1330)) \ 10
        IF zz < 0 THEN c = 14 ELSE c = 15
        LINE -(Xn, Yn), c
      END IF
skip:
NEXT xrot
'LOCATE 1, 1: PRINT xx, yy, zz
'LOCATE 2, 1: PRINT xrot, yrot, zrot
NEXT yrot
'page flip
SWAP ww, vv: SCREEN 9, , ww, vv:
WAIT &H3DA, 8: CLS : PRINT "3D Rotation demo by TH"
NEXT zrot
END

我来回复

您尚未登录,请登录后再回复。点此登录或注册