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
User avatar
Andrew Dance
Coder
Posts: 18
Joined: Mon Dec 17, 2007 8:41 pm
Contact:

first graphic based....game?

Post by Andrew Dance » Wed Dec 19, 2007 8:03 pm

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.

User avatar
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt » Wed Dec 19, 2007 10:20 pm

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.

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

Post by Andrew Dance » Wed Dec 19, 2007 10:37 pm

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 » Thu Dec 20, 2007 12:16 pm

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

Mac

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

Re: first graphic based....game?

Post by Andrew Dance » Thu Dec 20, 2007 1:22 pm

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

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

Post by sid6.7 » Thu Dec 20, 2007 1:29 pm

your last DO has no LOOP...how do you want it to go?

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

Post by Andrew Dance » Thu Dec 20, 2007 3:02 pm

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.

User avatar
Lachie Dazdarian
Veteran
Posts: 204
Joined: Mon Aug 30, 2004 6:18 am
Location: Croatia
Contact:

Post by Lachie Dazdarian » Thu Dec 20, 2007 5:28 pm

Would you consider please changing your bloated avatar?
Lachie Dazdarian - The Maker Of Stuff

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

Post by Andrew Dance » Thu Dec 20, 2007 8:25 pm

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 » Thu Dec 20, 2007 11:51 pm

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.

User avatar
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt » Fri Dec 21, 2007 12:10 am

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 » Fri Dec 21, 2007 9:50 am

Whoops, my bad...sorry Andrew...

Post Reply