Help w/ this code
Author Message Help w/ this code

Hi,
I am working on my first (very simple) game.  I cannot seem to get it to
work.  What I am trying to do is have it print "hit" when the yellow
pixel bumps into the white one.
Can anyone help??

SCREEN 7, 0, 1, 0
DO
DO
a\$ = INKEY\$
LOOP WHILE a\$ = ""
xbef = x
ybef = y
IF a\$ = "4" THEN x = x - 1
IF a\$ = "6" THEN x = x + 1
IF a\$ = "8" THEN y = y - 1
IF a\$ = "2" THEN y = y + 1
IF a\$ = CHR\$(27) THEN END
IF x < 1 THEN x = 1
IF y < 1 THEN y = 1
IF x > 317 THEN x = 317
IF y > 197 THEN y = 197
IF a\$ = "4" AND SCREEN(y, x - 1, 1) = 15 THEN PRINT "hit": END
IF a\$ = "6" AND SCREEN(y, x + 1, 1) = 15 THEN PRINT "hit": END
IF a\$ = "8" AND SCREEN(y - 1, x, 1) = 15 THEN PRINT "hit": END
IF a\$ = "2" AND SCREEN(y + 1, x, 1) = 15 THEN PRINT "hit": END
CLS
PSET (10, 10), 15
PSET (x, y), 14
PCOPY 1, 0
LOOP

Mon, 05 Jul 1999 03:00:00 GMT  Help w/ this code

Quote:

> Hi,
> I am working on my first (very simple) game.  I cannot seem to get it to
> work.  What I am trying to do is have it print "hit" when the yellow
> pixel bumps into the white one.
> Can anyone help??

Read up on POINT. Then use it in place of SCREEN.
SCREEN is used to return the ascii code or color of
a text character at the x,y position, POINT is for pixels.

--

Bangor, Pa. USA

Tue, 06 Jul 1999 03:00:00 GMT  Help w/ this code

What I am trying to do is have it print "hit" when the yellow

Quote:
> pixel bumps into the white one.
> Can anyone help??

Assuming you are using QBasic, and as you are using pixels,

CHANGE:

Quote:
> IF a\$ = "4" AND SCREEN(y, x - 1, 1) = 15 THEN PRINT "hit": END

TO:
If a\$="4" AND POINT(x, y) = 15 THEN
PRINT "hit"
END IF

SCREEN is used only for characters, and POINT is just used for pixels.
Hope this helps.

Paul Smitton.

Thu, 08 Jul 1999 03:00:00 GMT

 Page 1 of 1 [ 3 post ]

Relevant Pages