Page 1 of 1

moving pixel drawings

Posted: Mon Jun 25, 2007 4:58 pm
by Quicky
Hi again,

i am having trouble with moving graphics on the screen with my commands and the AI response ot my commands here is
an example without using graphics instead a 0

Code: Select all

attackrow = 12
attackcolumn = 40
row = 12
column = 10
DO
DO
keyed$ = INKEY$
LOOP UNTIL keyed$ <LOCATE> 1) THEN 
row = row - 1
end if
IF (keyed$ = CHR$(0) + CHR$(80)) AND (row <23> 1) THEN 
column = column - 1
end if
IF (keyed$ = CHR$(0) + CHR$(77)) AND (column < 80) THEN 
column = column + 1
end if
IF keyed$ = "e" THEN END
LOCATE row, column
COLOR 10
PRINT "0"

'AI
LOCATE attackrow, attackcolumn
PRINT " "
IF row <attackrow> attackrow THEN 
attackrow = attackrow + 1
end if
IF column <attackcolumn> attackcolumn THEN 
attackcolumn = attackcolumn + 1
end if
LOCATE attackrow, attackcolumn
COLOR 5
PRINT "0"
LOOP


And using that code above but modified i want to move this graphic for player 1
cls
screen 7
xlength = 6
ylength = 6
FOR x = 1 TO xlength
FOR Y = 1 TO ylength
READ z
PSET (x, Y), z

DATA 04,04,04,04,04,04
DATA 04,04,04,04,04,04
DATA 04,04,04,04,04,04
DATA 04,04,04,04,04,04
DATA 04,04,04,04,04,04
DATA 04,04,04,04,04,04


NEXT
NEXT

and this one for the AI

cls
screen 7
xlength = 8
ylength = 8
FOR x = 1 to xlength - 1
FOR y = 1 to ylength - 1
READ z
PSET (x, y), z
DATA 00, 00, 00, 14, 14, 00, 00, 00
DATA 00, 00, 00, 14, 14, 00, 00, 00
DATA 00, 00, 00, 14, 14, 00, 00, 00
DATA 14, 14, 14, 14, 14, 14, 14, 14
DATA 14, 14, 14, 14, 14, 14, 14, 14
DATA 00, 00, 00, 14, 14, 00, 00, 00
DATA 00, 00, 00, 14, 14, 00, 00, 00
DATA 00, 00, 00, 14, 14, 00, 00, 00
NEXT
NEXT

And finally once i have those i can firgure out how to not let the player/AI go through lines. the lines are basic draw command ones
(line(x1,y1)-(x2,y2), color)

could someone please help me i need it very bad

Posted: Mon Jun 25, 2007 8:29 pm
by Ralph
Could you first fix this part of your code?

Code: Select all

LOOP UNTIL keyed$ <LOCATE> 1) THEN 
row = row - 1 
end if 
Also, please note that:
Arrow Up = 0H = 0+CHR$(72)
Arrow Down = 0P = 0+CHR$(80)
Arrow Left = 0K = 0+CHR$(75)
Arrow Right = 0M = 0+CHR$(77)
You have some changes to make in your code!

fixed

Posted: Mon Jun 25, 2007 10:34 pm
by Quicky

Code: Select all

DO' fixed player1
DO
keyed$ = INKEY$
LOOP UNTIL keyed$ <LOCATE> 1) THEN 
row = row - 1
end if
IF (keyed$ = CHR$(0) + CHR$(80)) AND (row <23> 1) THEN 
column = column - 1
end if
IF (keyed$ = CHR$(0) + CHR$(77)) AND (column < 80) THEN 
column = column + 1
end if
IF keyed$ = "e" THEN END
LOCATE row, column
COLOR 10
PRINT "0"

'fixed AI
LOCATE attackrow, attackcolumn
PRINT " "
IF row <attackrow> attackrow THEN attackrow = attackrow + 1
IF column <attackcolumn> attackcolumn THEN attackcolumn = attackcolumn + 1
LOCATE attackrow, attackcolumn
COLOR 5
PRINT "0"
LOOP


umm

Posted: Mon Jun 25, 2007 10:35 pm
by Quicky
okay well it was fixed on preview but then it got messed up

Posted: Tue Jun 26, 2007 4:05 pm
by Ralph
Your present code has some basic lack of knowledge problems...

First, you ignored my post and copied from your old code.

Did you, perhaps, copy all the code from someone else? If you are trying to learn, I would recommend that you be humble about it, and ask one question at a time, where you either don't understand the code, or where you want to do something, but just don't know how to go about it.

Also, I would recomment that you read and understand all the tutorials that you can, and practice your QuickBASIC.