-
Mar 8th, 2018, 11:52 PM
#1
Thread Starter
New Member
[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
-
Mar 9th, 2018, 12:03 AM
#2
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.
-
Mar 9th, 2018, 12:26 AM
#3
Thread Starter
New Member
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.
-
Mar 9th, 2018, 10:49 AM
#4
Re: "Respawning" Bitmaps and adding lives
Originally Posted by Shappy
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.
-
Mar 9th, 2018, 03:01 PM
#5
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|