Reward system
Reward system
Reward system
Reward system
Reward system
Reward system Reward system Reward system Reward system Reward system Reward system Reward system Reward system
Reward system Reward system
Reward system
Go Back  Xtreme Visual Basic Talk > > > Reward system


Reply
 
Thread Tools Display Modes
  #1  
Old 03-08-2008, 09:42 AM
nhagan nhagan is offline
Newcomer
 
Join Date: Mar 2008
Posts: 15
Default Reward system


I weren't sure which section to put this under ;s so

Hello, i'm currently creating a simple game, where the user chooses a charcter, and they need to make it jump over a wall.

I currently have a textbox showing the user how many jumps they have made. And i would like to put in a system where:

When the user gets 3 jumps, they receive a reward in this case its a red heart. I want it so that a label appears telling the user they have been rewarded a heart - i know how to create the label with the ouput message, but do not know how to make it show when the user has 3 jumps. With the label i also want an image to appear. Which will be a heart (red)

Then when the user gets 3 hearts(red) They get a golden heart, therefore i need the same process to happen again but for the red hearts to disappear and a golden heart to show.

This process will happen until the user decides they want to quit the game so they can get an unlimited number of golden hearts, but the max number of red hearts they can get at a time is 3.

I was wondering if anyone could help me with the code for this.

This is the code for recording the jumps:

Code:
        If Jumping Then
            If JumpStepsTaken < NumStepsUp Then ' on way up
                ImgPerson.Top = ImgPerson.Top - JumpAmount ' move image up
                JumpStepsTaken = JumpStepsTaken + 1 ' record another jumpstep

            Else ' going down
                ImgPerson.Top = ImgPerson.Top + JumpAmount ' move image down
                JumpStepsTaken = JumpStepsTaken + 1 ' record another jumpstep
Thank you
Reply With Quote
  #2  
Old 03-08-2008, 04:51 PM
wolfstrike's Avatar
wolfstrike wolfstrike is offline
Junior Contributor
 
Join Date: Aug 2004
Posts: 336
Default

you can simply add a counter every time the player makes a successful jump.


depending on how you are drawing your graphics, the counter should be able to control when , where, and what to draw.

you can add a picture box for the hearts, or use your drawing system to place them in-game
__________________
The Pho·net·ic Programmer
Reply With Quote
  #3  
Old 03-09-2008, 01:03 PM
nhagan nhagan is offline
Newcomer
 
Join Date: Mar 2008
Posts: 15
Default

Still im a bit confused, i currently have a counter, which counts the number of jumps.

I need to know how i would make it so that every multiple of 3 they get a red heart.. but when the get 3 red hearts, they disappear and a gold heart appears..

Could someone please help
Reply With Quote
  #4  
Old 03-10-2008, 01:21 PM
wolfstrike's Avatar
wolfstrike wolfstrike is offline
Junior Contributor
 
Join Date: Aug 2004
Posts: 336
Default

Code:
Select case Jump_Counter
case 1 to 3:  ' draw one heart
case 4 to 6:  ' draw two hearts
case 7 to 9:  ' draw three hearts
case 10:  ' draw gold heart
end select
__________________
The Pho·net·ic Programmer
Reply With Quote
  #5  
Old 03-11-2008, 02:02 PM
JPB JPB is offline
Contributor
 
Join Date: Oct 2004
Posts: 629
Default

If you want to sequentially give red & gold hearts (nearly) infinitely, you can use this code:

Code:
Option Explicit

Private Const mclngJumpsPerReward As Long = 3    ' Number of jumps to receive a reward (i.e Red Heart)
Private Const mclngRewardsPerSuperReward As Long = 3    ' Number of rewards (i.e. red hearts) to receive a super reward (i.e. Gold Heart)

Public Function Rewards(ByVal pJumps As Long) As Long
   ' Calculate the number of rewards (i.e. red hearts) to receive for the passed number of jumps (pJumps)
   ' Taking into account received super rewards (i.e. gold hearts)
   Rewards = (pJumps - (SuperRewards(pJumps) * JumpsPerSuperReward)) \ mclngJumpsPerReward
End Function

Public Function SuperRewards(ByVal pJumps As Long) As Long
   ' Calculate the number of super rewards (i.e. gold hearts) to receive for the passed number of jumps (pJumps)
   SuperRewards = pJumps \ JumpsPerSuperReward
End Function

Private Function JumpsPerSuperReward() As Long
    ' Calculate the number of jumps required to get a super reward (i.e. gold heart)
   JumpsPerSuperReward = mclngJumpsPerReward * mclngRewardsPerSuperReward
End Function

Public Function CalcRewards()
   Dim i As Long
   
   For i = 0 To 30
      Debug.Print "Jumps: " & i & " RedHearts: " & Rewards(i) & " GoldHearts: " & SuperRewards(i)
   Next i
End Function
The CalcRewards function is just to print the proof that everything is calculating correctly (to the debug window). Here is the output for 0 to 30 jumps:

Code:
Jumps: 0    RedHearts: 0   GoldHearts: 0
Jumps: 1    RedHearts: 0   GoldHearts: 0
Jumps: 2    RedHearts: 0   GoldHearts: 0
Jumps: 3    RedHearts: 1   GoldHearts: 0
Jumps: 4    RedHearts: 1   GoldHearts: 0
Jumps: 5    RedHearts: 1   GoldHearts: 0
Jumps: 6    RedHearts: 2   GoldHearts: 0
Jumps: 7    RedHearts: 2   GoldHearts: 0
Jumps: 8    RedHearts: 2   GoldHearts: 0
Jumps: 9    RedHearts: 0   GoldHearts: 1
Jumps: 10   RedHearts: 0   GoldHearts: 1
Jumps: 11   RedHearts: 0   GoldHearts: 1
Jumps: 12   RedHearts: 1   GoldHearts: 1
Jumps: 13   RedHearts: 1   GoldHearts: 1
Jumps: 14   RedHearts: 1   GoldHearts: 1
Jumps: 15   RedHearts: 2   GoldHearts: 1
Jumps: 16   RedHearts: 2   GoldHearts: 1
Jumps: 17   RedHearts: 2   GoldHearts: 1
Jumps: 18   RedHearts: 0   GoldHearts: 2
Jumps: 19   RedHearts: 0   GoldHearts: 2
Jumps: 20   RedHearts: 0   GoldHearts: 2
Jumps: 21   RedHearts: 1   GoldHearts: 2
Jumps: 22   RedHearts: 1   GoldHearts: 2
Jumps: 23   RedHearts: 1   GoldHearts: 2
Jumps: 24   RedHearts: 2   GoldHearts: 2
Jumps: 25   RedHearts: 2   GoldHearts: 2
Jumps: 26   RedHearts: 2   GoldHearts: 2
Jumps: 27   RedHearts: 0   GoldHearts: 3
Jumps: 28   RedHearts: 0   GoldHearts: 3
Jumps: 29   RedHearts: 0   GoldHearts: 3
Jumps: 30   RedHearts: 1   GoldHearts: 3
Instead of referring to RedHearts and GoldHearts in the code, I used Rewards and SuperRewards. This way, in case you change the graphic from hearts, your code will still make sense.

I also used constants for the 2 reward levels so that if you change your mind about 3 jumps = 1 reward (red heart) and 3 rewards (red hearts) = 1 super reward (gold heart) you can just modify the values of the constants and the rest of the code can remain the same.

Lastly, you may have noticed that I used the backslash (\) for division instead of the more typical forward slash (/). This is to perform integer division (i.e. truncated decimal portion after division), which is both faster and more suited to the task (i.e. no accidental rounding up to produce incorrect results).

Hope this is useful!
Reply With Quote
  #6  
Old 03-11-2008, 06:57 PM
wolfstrike's Avatar
wolfstrike wolfstrike is offline
Junior Contributor
 
Join Date: Aug 2004
Posts: 336
Default

Quote:
This is to perform integer division

so thats why i was having problems with that one program i made last week!

__________________
The Pho·net·ic Programmer
Reply With Quote
  #7  
Old 03-14-2008, 02:20 AM
chris89's Avatar
chris89 chris89 is offline
Centurion
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 112
Default

Code:
Dim successJumpOverall as Integer Dim successJump as Integer Dim redHeartOverall as Integer Dim redHeart as Integer Dim goldHeartOverall as Integer Dim goldHeart as Integer Dim jumpSuccess as Boolean If jumpSuccess then successJumpOverall = successJumpOverall + 1 successJump = successJump + 1 end if if successJump = 3 then redHeartOverall = redHeartOverall + 1 redHeart = redHeart + 1 successJump = 0 end if if redHeart = 3 then goldHeartOverall = goldHeartOverall + 1 goldHeart = goldHeart = + 1 redHeart = 0 end if
__________________
Visual Basic, the cause and solution to all life's problems
Reply With Quote
  #8  
Old 03-14-2008, 11:52 AM
wolfstrike's Avatar
wolfstrike wolfstrike is offline
Junior Contributor
 
Join Date: Aug 2004
Posts: 336
Default

i don't think we helped him in time for his homework deadline
__________________
The Pho·net·ic Programmer
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Reward system
Reward system
Reward system Reward system
Reward system
Reward system
Reward system Reward system Reward system Reward system Reward system Reward system Reward system
Reward system
Reward system
 
Reward system
Reward system
 
-->