Quote: "we can't seem to get our sprite loading to replace the red/green square or getting an image to load in the background"
You are drawing the boxes incorrectly. At lines 18 - 19, you have
Box 50,1,9,9
Get Image 50,0,0,11,11
You started the box at pixel 50 and ended at pixel 9. This will not put anything on the screen. It should be:
Box 0,0,11,11
Get Image 50,0,0,11,11
Same thing with lines 27 - 28. You have:
Box 100,1,9,9
Get Image 100,0,0,11,11
which should be:
Box 0,0,11,11
Get Image 100,0,0,11,11
As to the background, I made up an image in place of your "textures-26.bmp" image (perhaps you could post the image you are using - it may be the problem.)
Quote: "If you press space bar you will see bullets fire but we're trying to fix that on the square where the gun should be."
I press the SPACEBAR, but no bullets are seen. I definitely would recommend using an image instead of text for the bullet, as it is way too slow and harder to use than making an image and using a sprite for it. Additionally, the text is straight up/down. What if the player is shooting to the side? You'd have to rotate it and stuff...kindof impractical.
Also, the code:
offset sprite 50,text width(a$)/2,text height(a$)/2
does not truly offset sprite 50 at it's center, as a$ is not defined in the code at all. Use 5 to offset it instead:
Additionally, sprite 50 is the green square, which you said represents the zombie. It really doesn't matter, so I set player to = 50.
You are using three arrays for the bullets:
Dim FiredBullet(MaxBullets)
Dim BulletPosX(MaxBullets)
Dim BulletPosY(MaxBullets)
I would suggest using one array with three elements, like this:
dim bullet(MaxBullets,3)
bullet(number,1) could equal the status (1 = fired, 0 = not fired)
bullet(number,2) = x position
bullet(number,3) = y position
Other notes:
__Use wrapvalue() to keep an angle within acceptable angles (see example).
__Typically, you will use SYNC at the end of your game loop. You would not want to add another SYNC in a subroutine, as it will dramatically slow down your game. I removed the one you had installed and I had to edit the speeds for everything as it simply was too fast.
I have revised your code a little bit. Take a look at it to see if this is what you were hoping to accomplish:
Rem Game Revamped
Set Display Mode 800,600,16
sync on : sync rate 100 : backdrop on : color backdrop 0
Hide Mouse
Set Text Opaque
Set Image ColorKey 255, 0, 255
player = 50 : PlayerSpeed = 2 : MaxRight = 800 : MaxDown = 600
MaxBullets = 20 : BulletImage = 2 : BulletSpeed = 3
dim bullet(MaxBullets,3)
rem setup player sprite
CLS RGB(255,0,0)
Ink RGB(0,255,0),0
Box 0,0,11,11
Get Image 50,0,0,11,11
sprite player,320,240,50
` Offset the sprite so it rotates in the center
offset sprite player,5,5
` SpriteAngle is a number between 0 and 359
rotate sprite player,0
rem setup zombie sprite
CLS RGB (0,255,0)
INK RGB (255,0,0), 0
Box 0,0,11,11
Get Image 100,0,0,11,11
sprite 100,320, 450, 100
offset sprite 100,5,5
rem Setup Background
Load Image "textures-26.bmp", 1
Sprite 1, 0, 0, 1
rem bullet image
load image "bullet.bmp",BulletImage
FireBulletDelay = timer() + 200
Rem Main Program Loop
Do
If Spacekey() = 1 and timer() > FireBulletDelay Then Gosub AddBullet
Gosub MoveBullet
Text 0,0,"Bullets On Screen: "+Str$(BulletCount)+" "
if upkey()
move sprite player,PlayerSpeed
Xpos = sprite x(player) : Ypos = sprite y(player)
` check to make sure it will stay on - screen
if Xpos < sprite width(player) or Xpos > (MaxRight - sprite width(player)) then move sprite player,-PlayerSpeed
if Ypos < Sprite height(player) or Ypos > (MaxDown - sprite height(player)) then move sprite player,-PlayerSpeed
endif
if downkey()
move sprite player,-PlayerSpeed
Xpos = sprite x(player) : Ypos = sprite y(player)
` check to make sure it will stay on - screen
if Xpos < sprite width(player) or Xpos > (MaxRight - sprite width(player)) then move sprite player,PlayerSpeed
if Ypos < Sprite height(player) or Ypos > (MaxDown - sprite height(player)) then move sprite player,PlayerSpeed
endif
` Add one to SpriteAngle and rotate sprite
if leftkey()
xa# = wrapvalue(Sprite Angle(player) - 3)
rotate sprite player,xa#
endif
` Subtract one from SpriteAngle and rotate sprite
if rightkey()
xa# = wrapvalue(Sprite Angle(player) + 3)
rotate sprite player,xa#
endif
text 0,0,str$(Sprite Angle(player))
Rem A.I. Chase Player (1)
sync
Loop
end
MoveBullet:
For N = 1 To MaxBullets
If bullet(n,1) = 1
move sprite 199 + n,BulletSpeed
Rem Check For Bullet Going Off Top Of Screen Here And Deal With It
Xpos = sprite x(199 + n) : Ypos = sprite y(199 + n)
If Xpos < 0 or Xpos > MaxRight or Ypos < 0 or Ypos > MaxDown
bullet(n,1) = 0 : ` status = off
if sprite exist(199 + n) = 1 then delete sprite 199 + n
Endif
Rem Check For Hit Enemy Here And Deal With It
Endif
Next N
Return
AddBullet:
available = 0
For N = 1 To MaxBullets
If bullet(n,1) = 0 then available = n : exit
next n
if available > 0
bullet(available,1) = 1 : ` status = fired
bullet(available,2) = sprite x(player) : ` set bullet's intial X position
bullet(available,3) = sprite y(player) : ` set bullet's initial Y position
xa# = sprite angle(player)
sprite 199 + available,bullet(available,2),bullet(available,3),BulletImage
rotate sprite 199 + available,xa#
FireBulletDelay = timer() + 200
endif
Return
I have attached the image that I used for the bullet.
Hope this is helpful.
LB