Re: A89: Need help with game
[Prev][Next][Index][Thread]
Re: A89: Need help with game
Umm... I whipped the left-right shifting real quick... if you need
vertical then I could do it, but I didn't since you only talked about
left and right in your email, anyways, here goes (with an example of
use).
_main:
jsr graphlib::clr_scr
move.w #72,d0
move.w #0,d1
lea sprite(pc),a0
bsr loadSprite
jsr graphlib::put_sprite
jsr userlib::idle_loop
rts
;loadSprite(...)
;Input:
; d0.w = x (See Note)
; d1.w = y
; a0.l = sprite (16X16)
;Output:
; d0.w = x (to draw at)
; d1.w = y
; a0.l = sprite (to draw)
;NO OTHER REGISTERS DESTROYED
;Note:
; The coordinate is now a signed value but be careful because the
;left-right values will only work correctly if the values fall "inside"
;a modulo 64, otherwise a -65, for example would look like -1 (This a
;proccesor resrtiction, it could be redone to avoid that if it is
needed).
loadSprite:
movem.l d2-d7/a1-a6,-(a7)
move.w #33,d7
lea tempSprite(pc),a1
\copySprite2Temp:
move.w (a0)+,(a1)+
dbra d7,\copySprite2Temp
tst.w d0
blt overLeft
cmp.w #160-16,d0
bgt overRight
exitLoadSprite:
lea tempSprite(pc),a0
movem.l (a7)+,d2-d7/a1-a6
rts
overLeft:
neg.w d0 ;How many to shift
move.w #16+15,d7 ;I shift the mask too
lea tempSprite+4(pc),a0 ;skip size
\shiftLeftLoop:
move.w (a0),d3
lsl.w d0,d3 ;Moves in 0's
move.w d3,(a0)+
dbra d7,\shiftLeftLoop
move.w #0,d0 ;New X to be returned
bra exitLoadSprite
overRight:
sub.w #160-16,d0 ;Amount to shift
move.w #16+15,d7
lea tempSprite+4(pc),a0
\shiftRightLoop:
move.w (a0),d3
lsr.w d0,d3 ; moves in 0's
move.w d3,(a0)+
dbra d7,\shiftRightLoop
move.w #160-16,d0 ;New X to be returned
bra exitLoadSprite
Scott Dial wrote:
>
> You have to shift the bytes in the sprite so that the sprite that is
> drawn appears to hang over the edge but doesn't. If you hung over the
> edge by 3 pixels then you do a lsl #3 to every row in the sprite; If you
> hung over the right side, shift to the right (rsl).Hanging over the
> bottom and top consists moving the words "up" and "down" in the sprite
> being drawn.
>
> BLoWh0Le@aol.com wrote:
> >
> > Hey, I've been contemplating how to tackle this problem for a while now. My problem is that I have to draw an explosion (a circle really) wherever a bullet lands in my game. This works fine in the middle of the screen, but when the bullet lands 16 or fewer pixels from the left side, I cannot use graphlib to display my explosion sprite.
> >
> > Anyone have any tips?
>
> --
> Scott "_Wrath_" Dial
> wrath@calc.org
> ICQ#3608935
> TimeCity AI Guy II - www.timecity.org
> Member of TCPA - tcpa.calc.org
> __________________________________________
> NetZero - Defenders of the Free World
> Get your FREE Internet Access and Email at
> http://www.netzero.net/download/index.html
--
Scott "_Wrath_" Dial
wrath@calc.org
ICQ#3608935
TimeCity AI Guy II - www.timecity.org
Member of TCPA - tcpa.calc.org
__________________________________________
NetZero - Defenders of the Free World
Get your FREE Internet Access and Email at
http://www.netzero.net/download/index.html
Follow-Ups:
References: