Posts: 650
Threads: 26
Joined: Aug 2004
if I were to have a pixel fall on another one, how would I do so with alot, I mean I could easily program just two pixels maybe with the collision code thing (if x1,y1 = x2,y2 then do whatever)
But I mean with hundreds of falling pixels with equal amount (or so)
staintionary pixels. Im thinking sub routines or sumtin
If I were to program them all I would go insane id probably kill someone in the process with little or no actual progress
Please help!
i have one more question but it can wait
quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote]
Here
Posts: 548
Threads: 67
Joined: Jun 2004
quote="na_th_an"]
Greenday, Spice Girls... Can you tell the difference?
[/quote]
Posts: 650
Threads: 26
Joined: Aug 2004
close but i meant all the pixels fall at one time like it's being possessed by gravity or something
kinda like it raining and hitting rocks...floating in mid-air or whatever.
quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote]
Here
Posts: 2,765
Threads: 138
Joined: Nov 2002
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 12
Threads: 2
Joined: Aug 2004
Could you give some more info on the specifics of the program? For example, would there be a specific number of pixels? Would they collide at the same point, or at different points? Etc.
hey say that if you play a Windows Install CD backwards, you can hear Satanic messages. That's nothing, play it forwards and it installs Windows.
Posts: 719
Threads: 72
Joined: Mar 2003
Code: TYPE Things
x AS SINGLE
y AS SINGLE
clr AS INTEGER
END TYPE
CONST Gravity! = .1
DIM Pixel(1 TO 100) AS Things
FOR pxl% = 1 TO 100
x% = RND * 320
y% = RND * 200
c% = INT(RND * 15)
Pixel(pxl%).x = x%
Pixel(pxl%).y = y%
Pixel(pxl%).clr = c%
NEXT pxl%
SCREEN 7, 0, 1, 0
DO
WAIT &H3DA, 8
WAIT &H3DA, 8, 8
CLS
''Point Of Gravity ; )
CIRCLE (160, 100), 5, 15
''Pull
FOR pxl% = 1 TO 100
grav.x! = Gravity! '(Pixel(pxl%).x * Gravity)
grav.y! = Gravity! '(Pixel(pxl%).y * Gravity)
IF Pixel(pxl%).x <= 160 THEN
Pixel(pxl%).x = Pixel(pxl%).x + grav.x!
ELSE
Pixel(pxl%).x = Pixel(pxl%).x - grav.x!
END IF
IF Pixel(pxl%).y <= 100 THEN
Pixel(pxl%).y = Pixel(pxl%).y + grav.y!
ELSE
Pixel(pxl%).y = Pixel(pxl%).y - grav.y!
END IF
PSET (FIX(Pixel(pxl%).x), FIX(Pixel(pxl%).y)), Pixel(pxl%).clr
NEXT pxl%
PCOPY 1, 0
LOOP UNTIL LEN(INKEY$)
END
I think that should do it....
Oz~
Edit: Fixed some of the code that doesn't work
Posts: 650
Threads: 26
Joined: Aug 2004
woah, that code's pretty complex. thanks though.
i can't seem to make out what i mean in words so:
the blue pixels fall and when one hits the brown one it randomly goes off in a direction and continues to fall.
quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote]
Here
Posts: 358
Threads: 15
Joined: May 2003
This isn't my code, but it may help.
It's called "Snow.bas"
Code: SCREEN 13
CLS
DEFINT A-Z
'init the palette
FOR I = 1 TO 60
OUT &H3C8, I
OUT &H3C9, I / 2 + 33
OUT &H3C9, I / 2 + 33
OUT &H3C9, I / 2 + 33
NEXT I
NUMFLK = 1000 'Number of flakes
'Define the snow flake variable type
TYPE snfk
X AS INTEGER
Y AS INTEGER
C AS INTEGER
END TYPE
'- -
'Draw what you want the snow to fall on here
COLOR 64
LOCATE 15, 15: PRINT "ESC to exit"
LOCATE 16, 9: PRINT "Any key to clear screen"
'- -
'Dimension the snow flake array
DIM FLK(NUMFLK) AS snfk
'Init the flakes pos and speed
FOR I = 1 TO NUMFLK
FLK(I).X = RND * 320
FLK(I).Y = -4000
FLK(I).C = RND * 50 + 50
NEXT I
'Move the flakes a little so they're not so bunched up
FOR REP = 1 TO 80
FOR I = 1 TO NUMFLK
FLK(I).Y = FLK(I).Y + FLK(I).C
NEXT I
NEXT REP
TIM! = TIMER
'Do the snow
DO
CNT = CNT + 1
RANDOMIZE TIMER
FOR I = 1 TO NUMFLK
MVD = 0 'Set up the
OY = FLK(I).Y '
OX = FLK(I).X '
OC = FLK(I).C 'temporary (not array is faster)
TC = OC '
TY = OY '
TX = OX 'variables
TYH = TY \ 100 'Set another variable
IF POINT(TX, TYH + 1) <> 0 AND TY > 2000 THEN 'Check if the current pixel is filled
MVD = 2
IF POINT(TX - 1, TYH + 1) = 0 THEN 'how about the down & left pixel?
IF POINT(TX - 1, TYH) = 0 THEN TX = TX - 1: MVD = 1 'no so move the pixel there
ELSEIF POINT(TX + 1, TYH + 1) = 0 THEN 'how about the down & right pixel?
IF POINT(TX + 1, TYH) = 0 THEN TX = TX + 1: MVD = 1 'no so move the pixel there
END IF
END IF
IF MVD = 2 THEN 'If the flake cant move then put it on the top
FLK(I).X = RND * 320
FLK(I).Y = 100
FLK(I).C = RND * 50 + 50
GOTO 1
END IF
TY = TY + TC 'Increment the flake vertically
PSET (OX, TYH), 0 'Erase the flake
PSET (TX, TY \ 100), TC - 40 'Draw the flake
FLK(I).X = TX ' Put the flake
FLK(I).Y = TY ' where its
FLK(I).C = TC 'supposed to be
1
NEXT I
A$ = INKEY$
IF A$ = CHR$(27) THEN EXIT DO
IF A$ <> "" THEN CLS
LOOP
SCREEN 12
PRINT CNT / (TIMER - TIM!)
DO
LOOP UNTIL INKEY$ = ""
PRINT "FAST SNOW ROUTINE BY DANNY BEARDSLEY (made in QB4.5)"
PRINT "COMPILE ME! 2 TIMES FASTER"
PRINT "COMPILE ME! 2 TIMES FASTER"
PRINT "COMPILE ME! 2 TIMES FASTER"
PRINT "________________________________________________________"
PRINT "This is a fast snow routine in 320X200 with 1000 flakes!"
PRINT " If you COMPILE it will be !!!2 times faster!!!!"
PRINT " I think that every variablle here is an integer"
PRINT " If you want more code for other amazing feats then>"
PRINT "--------------------------------------------------------"
PRINT "Email: dsb@cyberdude.com"
PRINT "Homepage: www.dnai.com/~beards"
PRINT "FREEWARE (just put my name in somewhere if you use it {:-)"
SLEEP
END
Posts: 719
Threads: 72
Joined: Mar 2003
Code: 'This TYPE command just sets up a property of a variable
TYPE Things
x AS SINGLE 'Position
y AS SINGLE
clr AS INTEGER 'Color
END TYPE
'This is how much our gravity will pull
CONST Gravity! = .1
'Create te pixels with the properties x, y, clr
DIM Pixel(1 TO 100) AS Things
'Randomly place all the pixels, with random colors
FOR pxl% = 1 TO 100
x% = RND * 320
y% = RND * 200
c% = INT(RND * 15)
Pixel(pxl%).x = x%
Pixel(pxl%).y = y%
Pixel(pxl%).clr = c%
NEXT pxl%
SCREEN 7, 0, 1, 0
DO
'VSync - don't worry about it...
WAIT &H3DA, 8
WAIT &H3DA, 8, 8
'Clear the Screen
CLS
''Point Of Gravity ; )
CIRCLE (160, 100), 5, 15 'Where everything is being pulled
''Pull
FOR pxl% = 1 TO 100
IF Pixel(pxl%).x <= 160 THEN
Pixel(pxl%).x = Pixel(pxl%).x + gravity! 'If its on the left of the gravity point, pull it right
ELSE
Pixel(pxl%).x = Pixel(pxl%).x - gravity! 'If its on the right...
END IF
IF Pixel(pxl%).y <= 100 THEN
Pixel(pxl%).y = Pixel(pxl%).y + gravity! 'If its above the gravity point, pull it down
ELSE
Pixel(pxl%).y = Pixel(pxl%).y - gravity! 'If its below...
END IF
PSET (FIX(Pixel(pxl%).x), FIX(Pixel(pxl%).y)), Pixel(pxl%).clr 'PSET the point on the screen
NEXT pxl%
PCOPY 1, 0 'Copy the work page to the visual
LOOP UNTIL LEN(INKEY$) 'Continue until a key is pressed
END
I think those comments should help
Oz~
Posts: 650
Threads: 26
Joined: Aug 2004
cool thanks!
i'll work with this for a while
quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote]
Here
|