'=========================================================================== ' Subject: STARFIELD WITH BACKGROUND MUSIC Date: 02-22-96 (20:58) ' Author: Tyler Barnes Code: QB, QBasic, PDS ' Origin: FidoNet QUIK_BAS Echo Packet: GRAPHICS.ABC '=========================================================================== 'Ok, here's a star field I wrote (The kind that has layered stars moving 'sideways) and it has background music. I can't say it couldn'y be programmed 'better, but it should give you an idea on how to do background music. By the 'way, when you run it, it'll ask for a bunch of settings. I suggest 75 star, 3 'layers, layer speeds at 1, 1.5, and 2, Music on. You may have to adjust these 'setting according to taste, and the speed of your computer. 'Oh, also, make all the stars move left. It looks stupid if they move in 'different directions. 'By D. Tyler Barnes '95 'Tested on a 486dx2 80mhz ON PLAY(1) GOSUB MuchMusic CLS INPUT "Number of stars:", StarNum% INPUT "Number of layers:", LNum% DIM StarX(StarNum%), StarY(StarNum%), Layer(LNum%) FOR L = 1 TO LNum% PRINT "Layer"; L; " speed:"; INPUT Layer(L) PRINT "Layer"; L; " direction [L/R]"; DO: K$ = UCASE$(INKEY$): LOOP UNTIL K$ = "L" OR K$ = "R" IF K$ = "L" THEN Layer(L) = -Layer(L) PRINT NEXT L PLAY ON PRINT "Music? [Y/N]"; WHILE A$ <> "Y" AND A$ <> "N": A$ = UCASE$(INKEY$): WEND IF A$ = "Y" THEN MBuff$ = "T150L2O3CGP16L16FEDL2>CC (StarNum% / LNum%) * CL THEN CL = CL + 1 StarX(I%) = StarX(I%) + Layer(CL) IF StarX(I%) < 1 THEN StarX(I%) = 319: StarY(I%) = RND * 199 IF StarX(I%) > 319 THEN StarX(I%) = 1: StarY(I%) = RND * 199 C% = (CL * 4) + 19 PSET (StarX(I%), StarY(I%)), C% NEXT I% LOOP UNTIL LEN(INKEY$) END MuchMusic: Count% = Count% + 1 SELECT CASE Count% CASE 0: MBuff$ = "T150L2O3CGP16L16FEDL2>CC