 |
|
| View previous topic :: View next topic |
| Author |
Message |
Groupie in Training

Joined: 20 Sep 2010 Posts: 126 Location: UK
|
Posted: Sat Jun 16, 2012 2:24 pm Post subject: Sprite Help Please |
|
|
Hi,
I'm working on a simple Basic program where an bird shaped object/sprite  is fired across the screen but am getting an Illegal Quantity Error when the X co-ordinates of the sprite reach 260.
Is anyone able to help (code below)
Also I have drawn a single colour sprite to be overlayed onto the multicolour sprite used above but am not sure how to achieve this (DATA included below) - does anyone have an example listing for both multicolour and single colour sprites?
Thanks
Lee
| Code: | 30 FOR T= 0 TO 62
40 READ U
50 POKE 12288+T,U
60 NEXT T
65 X=30:REM STARTING X POSITION
66 Y=220: REM STARTING Y POSITION
67 XVEL=8: REM X VELOCITY
68 YVEL=-8: REM Y VELOCITY
70 V=53248
80 POKE 2040,192
90 POKE V,Y:POKE V+1,X
100 POKE V+37,7
110 POKE V+38,1
120 POKE V+39,2
130 POKE V+28,1
140 POKE V+23,0:POKE V+29,0
150 POKE V+21,1
200 PRINT"XVEL" ; XVEL; " X";INT(X)
210 PRINT"YVEL" ; YVEL;" Y";INT(Y)
220 POKE V,INT(X):POKE V+1,INT(Y)
230 X=X+XVEL
231 Y=Y+YVEL
235 IF XVEL > 0 THEN XVEL=XVEL-.10
240 IF Y<210 THEN YVEL=YVEL+.45
245 IF Y>220 THEN YVEL=0
270 GOTO 200
1000 REM DATA FOR COLOUR SPRITE
1010 DATA 0,0,0
1020 DATA 40,168,0
1030 DATA 42,170,0
1040 DATA 10,174,160
1050 DATA 42,175,240
1060 DATA 42,191,240
1070 DATA 170,191,240
1080 DATA 170,191,212
1090 DATA 170,189,213
1100 DATA 170,173,84
1110 DATA 170,169,84
1120 DATA 170,169,84
1130 DATA 170,169,84
1140 DATA 170,169,168
1150 DATA 170,170,168
1160 DATA 42,170,160
1170 DATA 42,170,160
1180 DATA 42,190,160
1190 DATA 10,255,192
1200 DATA 3,255,0
1210 DATA 0,252,0
1220 REM DATA FOR SINGLE COLOUR OVERLAY SPRITE
1240 DATA 0,0,0
1250 DATA 40,168,0
1260 DATA 42,170,0
1270 DATA 10,174,160
1280 DATA 42,175,240
1290 DATA 42,191,240
1300 DATA 170,191,240
1310 DATA 170,191,212
1320 DATA 170,189,213
1330 DATA 170,173,84
1340 DATA 170,169,84
1350 DATA 170,169,84
1360 DATA 170,169,84
1370 DATA 170,169,168
1380 DATA 170,170,168
1390 DATA 42,170,160
1400 DATA 42,170,160
1410 DATA 42,190,160
1420 DATA 10,255,192
1430 DATA 3,255,0
1440 DATA 0,252,0 |
|
|
| Back to top |
|
 |
Lemon64 Game Champion


Joined: 29 Jan 2003 Age: 38 Posts: 3875 Location: Skegness, UK Fave game: The Sentinel
|
Posted: Sat Jun 16, 2012 3:03 pm Post subject: |
|
|
A memory location can only hold 0-255. So 260 is an illegal quantity.
There are 320 X positions, so how do you get at the last 64?
The sprite MSB or Most Significant Byte. This is is 53264 (V+16).
Like some of the other controls, each bit refers to a sprite. With a single sprite, POKE V+16,1 puts the sprite onto this right hand portion of the screen. POKE V+16,0 puts it back on the left.
One way to do it in your BASIC program would be to add a couple of lines.
260 IF X > 255 THEN MX=1: X=X-256:GOTO200
265 MX=0
And change line 220 to read
220 POKE V,X:POKE V+1,Y:POKEV+16,MX
This means if X is greater than 256, then MX is set to 1 and the sprite will appear on the right. If X is less than 255, MX will be zero and it appears on the left. _________________ |
|
| Back to top |
|
 |
Groupie in Training

Joined: 20 Sep 2010 Posts: 126 Location: UK
|
Posted: Tue Jun 19, 2012 5:37 pm Post subject: |
|
|
Thanks for that, got myself a copy of a Sprite programming book off Bombjack's excellent book site.
Thanks
Lee |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Tip: Get C64 Forever for super-comfy C64 emulation with pre-installed games, demos and other goodies!
Powered by phpBB © 2001, 2005 phpBB Group
|