回 帖 发 新 帖 刷新版面

主题:星空模拟

'我这里没加注释
DECLARE FUNCTION Get.PicNober! (x1&, y1&, x2&, y2&)
DEFINT A-Z
SCREEN 12
RANDOMIZE TIMER
DIM MyName(560) AS LONG
FOR i = 0 TO 559: READ MyName(i): NEXT
DIM StarPic(4, 2) AS LONG
FOR i = 0 TO 1
   CIRCLE (10, 10), i, 15
   PAINT (10, 10), 15, 15
   GET (10 - i, 10 - i)-(10 + i, 10 + i), StarPic(0, i)
   LINE (0, 0)-(20, 20), 0, BF
NEXT

PUT (175, 100), MyName, PSET
ERASE MyName
count = 200
DIM Star&(count, 6)
Midx& = 320: Midy& = 240

FOR i = 0 TO count - 1
   Star&(i, 2) = RND * 10 + .3
   Star&(i, 3) = RND * 6 + .2
   N = INT(RND * 2004) MOD 2
   IF N = 0 THEN
         Star&(i, 4) = -1
       ELSE
         Star&(i, 4) = 1
   END IF
   N = INT(RND * 2004) MOD 2
   IF N = 0 THEN
         Star&(i, 5) = -1
       ELSE
         Star&(i, 5) = 1
   END IF
   Star&(i, 0) = Midx& + Star&(i, 2) * Star&(i, 4)
   Star&(i, 1) = Midy& + Star&(i, 3) * Star&(i, 5)
   PUT (Star&(i, 0), Star&(i, 1)), StarPic(0, 0)
NEXT

WHILE INKEY$ = ""
  FOR i = 0 TO count - 1
     NN = Get.PicNober(Midx&, Midy&, Star&(i, 0), Star&(i, 1))
     PUT (Star&(i, 0), Star&(i, 1)), StarPic(0, NN)
     
     Star&(i, 0) = Star&(i, 0) + Star&(i, 2) * Star&(i, 4)
     Star&(i, 1) = Star&(i, 1) + Star&(i, 3) * Star&(i, 5)
     IF Star&(i, 0) > 630 OR Star&(i, 0) < 0 OR Star&(i, 1) < 0 OR Star&(i, 1) > 470 THEN
        Star&(i, 2) = RND * 10 + .3
        Star&(i, 3) = RND * 6 + .2
        N = INT(RND * 2004) MOD 2
        IF N = 0 THEN
              Star&(i, 4) = -1
           ELSE
              Star&(i, 4) = 1
        END IF
        N = INT(RND * 2004) MOD 2
        IF N = 0 THEN
             Star&(i, 5) = -1
           ELSE
             Star&(i, 5) = 1
        END IF
        Star&(i, 0) = Midx& + Star&(i, 2) * Star&(i, 4)
        Star&(i, 1) = Midy& + Star&(i, 3) * Star&(i, 5)
     END IF

     NN = Get.PicNober(Midx&, Midy&, Star&(i, 0), Star&(i, 1))
     PUT (Star&(i, 0), Star&(i, 1)), StarPic(0, NN)
  NEXT
WEND
END

DATA 1048856,133120,1052689,1074266112,4096,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,34078720,269488384,134217728
DATA 1048640,0,0,0,0,0,130111,135271441,1075576832,63551
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,33308416,269750528,469762056,16269120,0,0,0,0
DATA 0,-25229280,-2012152289,1089470464,1006637088,0,283115544,2083535884,800824,8126588
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,2131238912,285089790,-268435320
DATA 1056832,60,-536864768,809241616,205011068,2080406528,37812287,1209143313,1074790400,1711296552
DATA 0,811597848,-971479528,1862764,12976326,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,1090010880,303042818,268435528,5253184,102,1610618880,409344048,476867782
DATA -973027840,1149503520,1761483005,1141964800,-1040166876,0,811597824,101499440,3983046,393222
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,-2079842304,-31916732,285212776
DATA 5252164,194,1610612736,214052912,1019659782,100664832,806156351,672332819,1291649024,-1073704926
DATA -590947204,-60000712,202162224,7128774,393222,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,217595648,318509872,-50331608,9445964,-958628672,1819687132,213922044,1824966156
DATA 100664832,403701761,135661618,1343291392,-1073704926,1992713926,813091864,403488816,13424342,3932220
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,268435712,369635864,285212680
DATA 9445968,-966342976,1993087094,213921840,-858335720,1006648320,136316961,135985211,1077018624,-1073737695
DATA 1724278470,812043288,806142000,16701142,393222,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,537403648,452475656,838860808,1057088,-966342976,1724651622,213921840,-19474896
DATA 100664832,64575,137496662,1077411840,-1073737695,1623615174,812043288,1611448368,837318,393222
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,16531200,839407104,939524104
DATA 1057088,-966342976,1724651616,213921840,214353504,100664832,-130088927,148043859,-1605107712,-1040150494
DATA 1623615174,812043288,-1072905680,837318,393222,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,1056973056,-755477512,1409286152,9446048,-966342974,1724651616,214052912,214353600
DATA 100664832,69697,1209155728,-1605369856,1711312930,1623615174,912706584,-971479528,403467372,12982470
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,17842432,306221056,1342177352
DATA 9446048,-966343066,1724651616,409344054,208432326,-971454952,129215,-2012021217,277938176,1006653476
DATA -260146052,484867132,-30393332,404633656,8132732,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,33079040,318643968,-1862270840,5252112,2122087484,-428065552,809241628,507001086
DATA 2081979416,65537,336805904,135331840,20520,417792,3072,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,16777472,322965504,285212692
DATA 5253128,106954752,786432,0,0,0,67175425,571650064,236060672,4656
DATA 811008,52224,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,17039616,313528324,301989922,1191950,207618048,13369344,0,0
DATA 0,-16777473,1112542737,68419584,2624,16314368,30720,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,-65792,1343099390,335544386
DATA 671748,-118489088,7864320,0,0,0,0,-2145385450,1572864,1664
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,537138688,402653312,425984,0,0,0,0

DEFSNG A-Z
FUNCTION Get.PicNober (x1&, y1&, x2&, y2&)
   x = ABS(x2& - x1&)
   y = ABS(y2& - y1&)
   N = SQR(x * x + y * y)
   IF N < 80 THEN Get.PicNober = 0
   IF N > 79 THEN Get.PicNober = 1
END FUNCTION

回复列表 (共12个回复)

11 楼

TO javaest:
    我不得不说你的程序风格很糟糕,让人头疼
    另外程序调试了好久,都不能运行...让人更头疼

12 楼

我想问一下,那些DATA语句的定位那么困难,你怎么是一个一个打出点来的?

我来回复

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