first graphic based....game?

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Andrew Dance
Coder
Posts: 18
Joined: Mon Dec 17, 2007 8:41 pm
Contact:

first graphic based....game?

Post by Andrew Dance »

Yeah, its not really a game more than it is a test of my skills that i learned in the last day...

I know that its slow and skips a lot and crappy as hell, but its good enough for me because at least i understand DATA, DIM, GET, and PUT.

help as to why its skippy (and im sure it's because of the CLS every time you move) is greatly appreciated, because i like my little Bobby Blobby :3 and i want to turn him into a full fledged game eventually lol.

here's the source

edit: hmmm..i seem to of lost somehow my working version...strange.

Code: Select all

'blob facing rght
DATA 00,00,10,10,10,00,00,00,00
DATA 00,10,10,10,10,10,10,00,00
DATA 10,10,10,10,10,01,10,10,00
DATA 10,10,10,02,10,10,10,10,10
DATA 10,10,10,10,02,02,02,10,10
DATA 00,10,10,10,10,10,10,10,00
'blob facing left
DATA 00,00,00,00,10,10,10,00,00
DATA 00,00,10,10,10,10,10,10,00
DATA 00,10,10,01,10,10,10,10,10
DATA 10,10,10,10,10,02,10,10,10
DATA 10,10,02,02,02,10,10,10,10
DATA 00,10,10,10,10,10,10,10,00
'facing down sprite
DATA 00,00,00,00,00,00
DATA 00,00,10,10,00,00
DATA 00,10,10,10,10,00
DATA 10,10,10,10,10,10
DATA 10,10,10,10,10,10
DATA 10,01,10,10,01,10
DATA 02,10,10,10,10,02
DATA 10,02,02,02,02,10
DATA 00,10,10,10,10,00

SCREEN 7
CLS
COLOR 2, 6

'draw the sprites on screen so they can be stored in memory
FOR Y = 0 TO 5  ' For each row
  FOR X = 0 TO 8  ' For each column
    READ DotColor
    PSET (X, Y), DotColor
  NEXT X
NEXT Y

FOR Y = 6 TO 11  ' For each row
  FOR X = 0 TO 8  ' For each column
    READ DotColor
    PSET (X, Y), DotColor
  NEXT X
NEXT Y

FOR Y = 12 TO 20  ' For each row
  FOR X = 0 TO 5  ' For each column
    READ DotColor
    PSET (X, Y), DotColor
  NEXT X
NEXT Y

'Store the sprites to memory
DIM blobR%(0 TO 8, 0 TO 5)
DIM blobL%(0 TO 8, 6 TO 11)
DIM blobD%(0 TO 5, 12 TO 20)


GET (0, 0)-(8, 5), blobR%
GET (0, 6)-(8, 11), blobL%
GET (0, 12)-(5, 20), blobD%


CLS
bx = 50
by = 50

PUT (bx, by), blobR%

A$ = INKEY$

DO
	IF A$ = "d" THEN
		CLS
		bx = bx + 2
		PUT (bx, by), blobR%
	END IF

	IF A$ = "a" THEN
	       CLS
	       bx = bx - 2
	       PUT (bx, by), blobL%
	END IF

	IF A$ = "s" THEN
		CLS
		by = by - 2
		PUT (bx, by), blobD%
	END IF
LOOP






go crazy.

-Andrew
Last edited by Andrew Dance on Thu Dec 20, 2007 3:16 pm, edited 4 times in total.
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt »

The flicker is, of course, a result of the CLS. You're using SCREEN 7, which means you can always use screen pages. Look up how to do this in the QB help, it gives a pretty good explanation.

One suggestion I have for you: if you're going to use INKEY$, don't try doing $$$ against INKEY$ itself. Instead, create a variable and do it like this:

Code: Select all

A$ = INKEY$
IF A$ = "d" THEN
' your code here
etc etc etc.
Andrew Dance
Coder
Posts: 18
Joined: Mon Dec 17, 2007 8:41 pm
Contact:

Post by Andrew Dance »

Nodtveidt wrote:The flicker is, of course, a result of the CLS. You're using SCREEN 7, which means you can always use screen pages. Look up how to do this in the QB help, it gives a pretty good explanation.

yeah, i stumbled across the pages tutorial right after i posed this, and removed the flickering.

As for the buggy controls, im hoping what you said will help, using the variable and all.
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Re: first graphic based....game?

Post by Mac »

Andrew Dance wrote:here's the source
I only see a bit of the source.

Mac
Andrew Dance
Coder
Posts: 18
Joined: Mon Dec 17, 2007 8:41 pm
Contact:

Re: first graphic based....game?

Post by Andrew Dance »

Mac wrote:
Andrew Dance wrote:here's the source
I only see a bit of the source.

Mac
its all there

it ends with the

Code: Select all

END IF
sid6.7
Veteran
Posts: 318
Joined: Tue Jun 21, 2005 8:51 am
Location: west USA
Contact:

Post by sid6.7 »

your last DO has no LOOP...how do you want it to go?
Andrew Dance
Coder
Posts: 18
Joined: Mon Dec 17, 2007 8:41 pm
Contact:

Post by Andrew Dance »

sid6.7 wrote:your last DO has no LOOP...how do you want it to go?
ok, that is just a typo, lol. its fixed now, and i edited the code box in the first post to match what it is now.
Lachie Dazdarian
Veteran
Posts: 202
Joined: Mon Aug 30, 2004 6:18 am
Location: Croatia
Contact:

Post by Lachie Dazdarian »

Would you consider please changing your bloated avatar?
Lachie Dazdarian - The Maker Of Stuff
Andrew Dance
Coder
Posts: 18
Joined: Mon Dec 17, 2007 8:41 pm
Contact:

Post by Andrew Dance »

Lachie Dazdarian wrote:Would you consider please changing your bloated avatar?
if you have a problem with my avatar, PM me, don't crap up a thread with irrelevant things. its under 150x150 so whats the big deal?
BDZ
Coder
Posts: 49
Joined: Sun Nov 20, 2005 5:41 pm
Location: Wisconsin
Contact:

Post by BDZ »

Andrew Dance wrote:
Lachie Dazdarian wrote:Would you consider please changing your bloated avatar?
if you have a problem with my avatar, PM me, don't crap up a thread with irrelevant things. its under 150x150 so whats the big deal?
Avatar rules as stated right above where you upload an avatar:
Only one image can be displayed at a time, its width can be no greater than 80 pixels, the height no greater than 80 pixels, and the file size no more than 6 KB.
I daresay 149 pixels is greater than 80 pixels, and as amazing as Rumsfield folding a crane is, it's a whole lot larger than 6 KB.
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt »

That rule only applies to images uploaded to the server. His avatar is remotely linked and therefore isn't forced to conform to the avatar ruleset. 150x150 is the generally accepted standard for forum avatars across the web, it's considered bad netiquette to use larger images.
BDZ
Coder
Posts: 49
Joined: Sun Nov 20, 2005 5:41 pm
Location: Wisconsin
Contact:

Post by BDZ »

Whoops, my bad...sorry Andrew...
Post Reply