multiple weapons...

digit2600

Member
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 ?
 

dale_coop

Moderator
Staff member
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)?
 

Mugi

Member
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:
doDrawWeapon:
     
     DrawSprite temp, temp1, #SPR_WEAPON, temp2, spriteOffset
     JMP doneDrawingWeaponSprite

into:

Code:
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
 

Mugi

Member
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:
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.
 

digit2600

Member
At the moment, at least until I figure out an inventory system, gonna have to go with each weapon replacing previous one.
 

Mugi

Member
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

Member
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.
 

digit2600

Member
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... ?
 

TurtleRescueNES

Active member
digit2600 said:
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... ?

In theory, you could draw a second sprite, but to coordinate the x and y of that based on the direction you face could get ugly.

The easier solution, and one I am using, is discarding draw sprite and going with the 4.0.6 weapon creation style of create object.
You have more control of your weapon size, strength and animations with game objects.

I think there are some threads about that. Look for melee weapons or melee objects.
 

Mugi

Member
sprite weapon should draw 2 sprites if you just set the size of it in predraw where it draws it on.
i mean, even Joes bunny game tutorial used a sprite weapon that was 2 sprites.
 

digit2600

Member
Mugi said:
sprite weapon should draw 2 sprites if you just set the size of it in predraw where it draws it on.
i mean, even Joes bunny game tutorial used a sprite weapon that was 2 sprites.

There are two predraw codes... one is labelled spriteWeapon, the other just preDraw... Both reference sprite based weapons, but even after changing the number up and down, it for some reason has not worked.. Maybe it is changing the size of the sprite itself, but I think that sprite #71 (where my weapon is) is the only thing that is being read instead of 71 & 72... Just looked at joe tut, it's only one sprite, 8x8... the pickup tile is 4, but the actual weapon is just 1.
 

Mugi

Member
have to say i never tried messing with it since my weapon is a single sprite, but i'll take a look and see.
 

Mugi

Member
yeha, you're right actually, changing the width values on the predraw doesnt actually draw more, it just changes the area of the sprite that's drawn.
to rectify that, you'll have to add more lines to the doDrawWeapon label to draw the rest of it.

Code:
     DrawSprite temp, temp1, #SPR_WEAPON, temp2, spriteOffset

to contain a drawsprite for each sprite your weapon uses.
for that basically you'll have to take the first line shown here, and draw that, then add to the position values (temp and temp1) to move 8pixels from the original, and instead of #SPR_WEAPON, define the second piece of the weapon to draw.

it's doable but that gets janky pretty fast. Also, your weapons should all have the same size if you do this, othervise you'll have to dublicate this script or code in some silly amount of conditions to draw it differently based on which weapon you have in use.
 

digit2600

Member
I'm already expecting them to be about the same size, at least until I get more comfortable with asm.. at this stage, I just wanna ditch my shitty dagger and set up Johnny's chainsaws trusty baseball bat, because that's how a man kills zombies.
 
Top Bottom