Qbasicnews.com
December 13, 2019, 02:02:55 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: Multiple Pixels  (Read 3228 times)
DinoKilla
New Member

Posts: 3


« on: August 24, 2007, 01:53:29 AM »

Hello, I know this is probably simple for most people but I'm having a hard time figuring it out.  What I'm trying to do is to get a pixel shoot accross the screen from a certain point everytime a certain key is pressed...the problem I'm having is I want to be able to press the key in rapid succession, only everything I try has to finish executing the second, third or whichever shot then it goes back to the shot before it and finishes it and the goes to the first shot and finishes it...not at ALL how I want it.  Any advice? I'm pretty much a QB newb but I should be able to get anything you can tell me.  Thanks.
Logged
wildcard
*.*
Administrator
__/--\__
*****
Posts: 2369



« Reply #1 on: August 24, 2007, 08:59:20 AM »

What most programs do when they need to fire multiple objects is to use an array of them, but it does make it slightly more complicated. I'll see if I get a chance to make an example.
Logged
barok
Na_th_an
*****
Posts: 1727


How about a tasty lead sandwich?


« Reply #2 on: August 24, 2007, 02:29:50 PM »

any chance we could see your source code to see what your doing?  i don't know if i quite follow what your trying to do.  seems to me to be some basic particle handling.
Logged

Jumping Jahoolipers!
Mac
Senior Member
**
Posts: 243


WWW
« Reply #3 on: August 24, 2007, 02:41:02 PM »

Here is a demo of a particle moving.

Fire more than once to see two moving at the same time.

Mac

http://www.network54.com/Forum/190883/message/1179497831/
Logged
DinoKilla
New Member

Posts: 3


« Reply #4 on: August 25, 2007, 11:08:12 PM »

Well I don't have any source, but basically it's kinda like that link to that little game there except I would like to shoot just single pixels in screen 13 but I don't want to be limited to X amount I would like to be able to just keep pressing a button and firing bullets(pixels) as much and as fast as I want.  Like I said before though my main problem is that I can only control 1 pixel at a time and it interrupts the flight of the previous pixels.  So lets say if I made a type with an X and Y value and I made an array of MyType could I somehow have a loop that would always update MyType(i).X and MyType(i).Y or something?  It's causing me alot of trouble but I know it's probably really easy.  Thanks for the help, more help would be appreciated too. =)
Logged
Mac
Senior Member
**
Posts: 243


WWW
« Reply #5 on: August 28, 2007, 10:21:19 PM »

Code:
TYPE Pixel
colr AS INTEGER ' Color
curh AS INTEGER
curv AS INTEGER
goalh AS INTEGER
goalv AS INTEGER
END TYPE
CONST MaxPixels = 20
DIM p(MaxPixels) AS Pixel
SCREEN 13
DO
  FOR i = 1 TO MaxPixels
    IF p(i).colr = 0 THEN
      p(i).colr = 15 '3 + INT(RND * 3)
      p(i).curh = 150
      p(i).curv = 100
      p(i).goalh = RND * 300
      p(i).goalv = RND * 200
      PSET (p(i).goalh, p(i).goalv), 12
    ELSE
      Match = 0
      PSET (p(i).curh, p(i).curv), 0: ' Erase old pixel
      SELECT CASE p(i).curh
      CASE IS < p(i).goalh: p(i).curh = p(i).curh + 1
      CASE IS > p(i).goalh: p(i).curh = p(i).curh - 1
      CASE IS = p(i).goalh: Match = 1
      END SELECT
      SELECT CASE p(i).curv
      CASE IS < p(i).goalv: p(i).curv = p(i).curv + 1
      CASE IS > p(i).goalv: p(i).curv = p(i).curv - 1
      CASE IS = p(i).goalv: Match = Match + 1
      END SELECT
      IF Match = 2 THEN
        p(i).colr = 0
      ELSE
        PSET (p(i).curh, p(i).curv), p(i).colr
      END IF
    END IF
    IF c = 3 THEN c = 0: WAIT &H3DA, 8: WAIT &H3DA, 8, 8 ELSE c = c + 1
  NEXT i
  FOR i = -1 TO 1: FOR j = -1 TO 1: PSET (150 + i, 100 + j), 8: NEXT j: NEXT i
LOOP WHILE INKEY$ = ""
END
Logged
DinoKilla
New Member

Posts: 3


« Reply #6 on: August 30, 2007, 03:07:23 AM »

Thank you very much, that is EXACTLY what I'm trying to do.  All help is much appreciated...I'm sure I will be back in the future with more questions!  Grin  Thanks again for all the help.
Logged
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!