multiple weapons...

digit2600
Posts: 101
Joined: Mon Apr 16, 2018 9:50 pm

multiple weapons...

Post by digit2600 » Mon Feb 11, 2019 10:00 am

Ok... so, I'm trying to do this:

If(attacking{
If (baseball bat equipped){changeSpriteWeapon}
If (chainsaw equipped){changeSpriteWeapon}
If (2x4 with nails in it equipped){changeSpriteWeapon}
}
Etc

I can only figure

Cmp #$03
Bne not attacking
Cmp bat
Beq got bat
Cmp chainsaw
Beq got chainsaw
Cmp 2x4
Beq got 2x4
Jmp
Got bat:
Cmp #$03
Bne not attacking
ChangeSpriteWeapon
Rts
Got chainsaw....repeat process ?
User avatar
dale_coop
Posts: 2561
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: multiple weapons...

Post by dale_coop » Mon Feb 11, 2019 12:11 pm

Are you using the sprite base weapon or the melee object one?
What are the names of your variables? How do you get weapon... how do you equip? Or maybe when the player got a weapon it replaces the previous one (so auto equip)?
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE
User avatar
Mugi
Posts: 287
Joined: Thu Dec 27, 2018 8:30 pm

Re: multiple weapons...

Post by Mugi » Mon Feb 11, 2019 12:31 pm

for sprite weapons the easiest way to do that would propably be something along the lines of....

1) make your weapon pickup items all set a variable.
2) change your sprite weapon code in predraw.asm to read that variable, and set the #SPR_WEAPON to a different value based on the variable, and do the same with the weapon size values..

it would be something along the lines of changing:

Code: Select all

doDrawWeapon:
     
     DrawSprite temp, temp1, #SPR_WEAPON, temp2, spriteOffset
     JMP doneDrawingWeaponSprite
into:

Code: Select all

doDrawWeapon:
     LDA whateveryourweaponvariableiscalled
     CMP #$00
     BEQ drawweapon1
     CMP #$01
     BEQ drawweapon2
     ; do this for as many weapons you have
     RTS

drawweapon1:
     LDA #$00		; set this to the number of the first weapon you want to draw
     STA #SPR_WEAPON
     DrawSprite temp, temp1, #SPR_WEAPON, temp2, spriteOffset
     JMP doneDrawingWeaponSprite

drawweapon2:
     LDA #$01		; set this to the number of the second weapon you want to draw
     STA #SPR_WEAPON
     DrawSprite temp, temp1, #SPR_WEAPON, temp2, spriteOffset
     JMP doneDrawingWeaponSprite
User avatar
Mugi
Posts: 287
Joined: Thu Dec 27, 2018 8:30 pm

Re: multiple weapons...

Post by Mugi » Mon Feb 11, 2019 12:38 pm

actually, that wouldn't work because #SPR_WEAPON is a constant. heh... i just pulled that out of my ass....

could do like... make each of your weapons set a variable, but make it set the variable to the value of the weapon you want to draw. (the coordinate of the tile in the tileset, just like you would define the SPR_WEAPON for a single weapon.)

then just change the weapondrawcode to:

Code: Select all

doDrawWeapon:
     
     DrawSprite temp, temp1, whateveryourweaponvariableiscalled, temp2, spriteOffset
     JMP doneDrawingWeaponSprite
this will make it draw the sprite defined in your variable, which is set by the pickup when you get a weapon.
User avatar
dale_coop
Posts: 2561
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: multiple weapons...

Post by dale_coop » Mon Feb 11, 2019 4:48 pm

Agree with Mugi.
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE
digit2600
Posts: 101
Joined: Mon Apr 16, 2018 9:50 pm

Re: multiple weapons...

Post by digit2600 » Tue Feb 12, 2019 1:44 am

At the moment, at least until I figure out an inventory system, gonna have to go with each weapon replacing previous one.
User avatar
Mugi
Posts: 287
Joined: Thu Dec 27, 2018 8:30 pm

Re: multiple weapons...

Post by Mugi » Tue Feb 12, 2019 1:58 am

For that you could simply make a war like... Numberofweapons or something of the sort and based on the value of it you could make select button (or whatever button) cycle the obtained ones.
digit2600
Posts: 101
Joined: Mon Apr 16, 2018 9:50 pm

Re: multiple weapons...

Post by digit2600 » Tue Feb 12, 2019 7:12 am

For a guy who says he ain't a programmer, mugi, you really are saving my ass here dude ! Thanks, Cant want to get on this shit tomorrow.
User avatar
Mugi
Posts: 287
Joined: Thu Dec 27, 2018 8:30 pm

Re: multiple weapons...

Post by Mugi » Tue Feb 12, 2019 7:25 am

Well, dd is actually the first thing ive put some proper code into :p
digit2600
Posts: 101
Joined: Mon Apr 16, 2018 9:50 pm

Re: multiple weapons...

Post by digit2600 » Tue Feb 12, 2019 1:30 pm

Something I'm fighting with right now... Any idea how to make the sprite based weapon two tiles ? I'm messing with the predraw width and spriteweapon width, but getting nowhere... ?
Post Reply