Results 1 to 5 of 5

Thread: [RESOLVED] "Respawning" Bitmaps and adding lives

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2017
    Posts
    8

    Resolved [RESOLVED] "Respawning" Bitmaps and adding lives

    Hiya,

    i'm building a small game and seem to be having trouble with having my code respawn a projectile

    currently i'm using an if statement

    the projectiles are stored as Bitmap graphics

    Code:
    if cshtProjectileX >= pnlGame.width then 
    graProjectile.translatetransform(-3,0)
    else if cshtProjectileX <= pnlGame.Width then
    CshtProjectileX = 401
    graProjectile.translatetransform(-3,0)
    the Object Moves successfully the first time through but wont respawn

    as for the Lives matter, i have something like this

    Code:
    if intPoints = 100 then
    Health += 1
    lblHealth.text = Health.tostring
    this works successfully for the first 100 points, how would i go about it for every 100 points?

    Thank you
    -Shappy

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,116

    Re: "Respawning" Bitmaps and adding lives

    For the second question, something like this should work:

    Code:
    If intPoints > 0 AndAlso intPoints Mod 100 = 0 Then
      Health += 1
      lblHealth.Text = Health.ToString
    https://docs.microsoft.com/en-us/dot...s/mod-operator

    Edit: This code assumes that your score increases in such a way that the score will always exactly reach multiples of 100. If there is a chance that your score will go from 99 to 101, for example, then the above code won't work the way you want it to and additional code would need to be written to accommodate that scenario.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2017
    Posts
    8

    Re: "Respawning" Bitmaps and adding lives

    Thank you so much, the answer was definitely easier then what i was making it out to be for the life system.

  4. #4
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: "Respawning" Bitmaps and adding lives

    Quote Originally Posted by Shappy View Post
    Hiya,

    i'm building a small game and seem to be having trouble with having my code respawn a projectile

    currently i'm using an if statement

    the projectiles are stored as Bitmap graphics

    Code:
    if cshtProjectileX >= pnlGame.width then 
    graProjectile.translatetransform(-3,0)
    else if cshtProjectileX <= pnlGame.Width then
    CshtProjectileX = 401
    graProjectile.translatetransform(-3,0)
    ...
    I can't quite figure out what that code is doing, it doesn't make sense to me.
    Is CshtProjecttileX even being modified?
    You're doing a graProjectile.translatetransform(-3,0) which will change where coordinate (0,0) is relative to things being drawn using graProjectile, but that won't change the X or Y coordinates of anything being drawn, it just changes the coordinate space being drawn on.

    I'm thinking that you're not using translatetransform the way it should be used, but I'm not sure what graProjectile is either. I would guess a graphics object, but perhaps its a textureBrush reference or something else.

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2017
    Posts
    8

    Re: "Respawning" Bitmaps and adding lives

    graPrjectile would be a graphics object, and I think I understand what you mean the image might look as it’s moving but it’s coordinates aren’t being changed.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width