Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Palletes an rain
#1
Hey do any of u guys know how i would go about making rain?

It doesnt need to be transparent or anything, just rain diagonally or more helpful, downwards.

Also, what is a pallete, and why would i need one for a game? isnt 256 colours enuff?

thanks in advance.
LA BLA BLA
Reply
#2
Note the credit at the end...this is not my code.

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
Reply
#3
doesn't change the number of colors available. It just changes what the colors are (if I understood that part of your question right).
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply
#4
ok, thanks, but, how would i go about making my own? why would i need a new pallete?
LA BLA BLA
Reply
#5
Because you don't want blackish red rain.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#6
Mode 13h (SCREEN 13) can have 256 different colors on the screen at any given point. These colors can be selected from an 18 bit rgb palette, giving you a total of a little over 260,000 colors that these 256 palettes can be. Think of it like having an art palette with room for 256 different paints.

256 colors is plenty, but you're going to want a custom palette if you're making a tileset, but the one qb gives you just isnt very good, there are a lot of useful colors missing. You can change any one of the colors by doing the following:

Code:
out &h3c8, colortochange
out &h3c9, redvalue '0-63
out &h3c9, greenvalue '0-63
out &h3c9, bluevalue '0-63
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#7
Look @ the fabulous FAQ feature:: http://faq.qbasicnews.com/?blast=General...xplanation
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#8
thanks guys helps alot!
LA BLA BLA
Reply
#9
I read that link, but it doesnt tell me how to actually change the port values, any ideas?
LA BLA BLA
Reply
#10
Quote:I read that link, but it doesnt tell me how to actually change the port values, any ideas?

Uh? :o

I think it does:

Quote:Or we can use OUTs to the DAC ports of the VGA (fast)...

Code:
OUT &H3C8, slot
OUT &H3C9, red
OUT &H3C9, green
OUT &H3C9, blue

That actually changes the port values... What's wrong with that?

Check this out also: http://qbasicnews.com/qboho/qckout.shtml
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)