Hi,
Can QPTR SPRITES, be used in games?
Sprites
-
- Font of All Knowledge
- Posts: 4038
- Joined: Mon Dec 20, 2010 11:40 am
- Location: Sunny Runcorn, Cheshire, UK
Re: Sprites
You can, of course, do something like that (Provided that you have QPTR loaded):
As always with S*BASIC, you might want to adjust the delay in line 540 to accommodate your QPC, and the limits in line 410 and 430 need to be adapted to your window size. It's relatively unlikely that anything but a fast emulator is quick enough for smooth animation from S*BASIC, however.
BTW: With newer Turbo compilers, this does compile and run fine, even if the QPTR manual says otherwise.
Code: Select all
100 REMark Test whether QPTRsprites are any good for animation....
110 spr32=ALCHP(SPRSP(20,10))
120 REMark define a sprite for mode we're in
130 SPHDR spr32;20,10,0,0;RMODE
140 linum% = 0
150 SPLIN spr32,linum%,' uu '
160 SPLIN spr32,linum%,' u yy u '
170 SPLIN spr32,linum%,' w yy w '
180 SPLIN spr32,linum%,' wuuwwuuw '
190 SPLIN spr32,linum%,' yyyy '
200 SPLIN spr32,linum%,' ayyyya '
210 SPLIN spr32,linum%,' aayyyyaa '
220 SPLIN spr32,linum%,'a aayyaa a'
230 SPLIN spr32,linum%,'a ayyyya a'
240 SPLIN spr32,linum%,'aaauuuuaaa'
250 :
260 REMark Now the keyboard loop
270 x% = 100 : y% = 100
280 REMark set up a background buffer
300 buffer = PSAVE (0; 0, 0; 20, 10, 100, 100; 20, 10)
310 REPeat k_loop
320 k = KEYROW(1)
340 xold% = x% : yold% = y%
350 SELect ON k
360 =8: EXIT k_loop :REMark ESC pressed
370 =1: REMark ENTER
380 =2: x% = x% - 2: REMark LEFT
390 IF x% < 0 : x% = 0
400 =16: x% = x% + 2 : REMark right
410 IF x% > 512 : x% = 512
420 =128: y% = y% + 2 : REMark down
430 IF y% > 256 : y% = 256
440 =4: y% = y% - 2: REMark up
450 IF y% < 0 : y% = 0
460 END SELect
470 REMark restore screen under sprite, keep buffer
480 PREST buffer, 0, 0; 20, 10; xold%, yold%; 1
490 REMark Now save area under new sprite
500 dummy = PSAVE(buffer; 0, 0; 20, 10; x%, y%)
510 REMark and display the sprite
520 WSPRT x%, y%, spr32
530 REMark wait a tick to slow down the computer
540 SUSJB -1,1
550 END REPeat k_loop
BTW: With newer Turbo compilers, this does compile and run fine, even if the QPTR manual says otherwise.
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
-
- Font of All Knowledge
- Posts: 4038
- Joined: Mon Dec 20, 2010 11:40 am
- Location: Sunny Runcorn, Cheshire, UK
Re: Sprites
Hi Tofro,
Excellent, just confirms what I thought, ever since I bought the QPTR Toolkit when it first appeared, I did wonder if this could done. Which relied on the purchsse of QPTR Toolkit, but now QPTR is free, this might a good solution.
Excellent, just confirms what I thought, ever since I bought the QPTR Toolkit when it first appeared, I did wonder if this could done. Which relied on the purchsse of QPTR Toolkit, but now QPTR is free, this might a good solution.
Regards,
Derek
Derek