Qbasicnews.com
March 30, 2020, 10:10:43 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Palletes an rain  (Read 2745 times)
prof_flex
Member
*
Posts: 37


« on: June 05, 2003, 09:57:36 AM »

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.
Logged

LA BLA BLA
Mango
Wandering Guru
***
Posts: 360



« Reply #1 on: June 05, 2003, 11:04:11 AM »

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
Logged
Glenn
I hold this place together
*****
Posts: 786



WWW
« Reply #2 on: June 05, 2003, 11:20:21 AM »

doesn't change the number of colors available.  It just changes what the colors  are (if I understood that part of your question right).
Logged

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.
prof_flex
Member
*
Posts: 37


« Reply #3 on: June 05, 2003, 11:45:10 AM »

ok, thanks, but, how would i go about making my own? why would i need a new pallete?
Logged

LA BLA BLA
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #4 on: June 05, 2003, 11:48:29 AM »

Because you don't want blackish red rain.
Logged

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.
toonski84
__/--\__
*****
Posts: 2567



« Reply #5 on: June 05, 2003, 12:55:44 PM »

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
Logged

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
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #6 on: June 05, 2003, 04:53:53 PM »

Look @ the fabulous FAQ feature:: http://faq.qbasicnews.com/?blast=GeneralPaletteExplanation
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
prof_flex
Member
*
Posts: 37


« Reply #7 on: June 06, 2003, 03:40:43 AM »

thanks guys helps alot!
Logged

LA BLA BLA
prof_flex
Member
*
Posts: 37


« Reply #8 on: June 06, 2003, 03:57:16 AM »

I read that link, but it doesnt tell me how to actually change the port values, any ideas?
Logged

LA BLA BLA
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #9 on: June 06, 2003, 10:13:36 AM »

Quote from: "prof_flex"
I read that link, but it doesnt tell me how to actually change the port values, any ideas?


Uh?  Shocked

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
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Neo
Na_th_an
*****
Posts: 2150



« Reply #10 on: June 06, 2003, 10:19:15 AM »

prof_flex: 3C8h and 3C9h are both ports of the videocard. Writing to them does change the port values. Why not, according to you?
Logged
prof_flex
Member
*
Posts: 37


« Reply #11 on: June 06, 2003, 02:55:15 PM »

yeah, but it doesnt say like how to actuaklly put your own values in.

&H3CA, 9 or wot eva it is

doesnt that just access the port? how do i put my own colors in?

Ive seen examples where they have &H3CA, 9  T/ red * 65

i thought something went after it to change the value?

plz help?
Logged

LA BLA BLA
Glenn
I hold this place together
*****
Posts: 786



WWW
« Reply #12 on: June 06, 2003, 03:49:53 PM »

Writing to a port is "accessing" the port...

OUT &H3C9, 10

writes the byte 10 to the register referenced by port 3C9h, or more briefly, just writes the byte 10 to port 3C9h (i.e., changes the value at that register to 10).  (And reading from a port is also "accessing" the port.)
Logged

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.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!