Time Bonus Needed

This forum is meant for requesting technical support or reporting bugs.

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

Time Bonus Needed

Postby Ikonz101 » Sat Oct 03, 2009 2:46 am

Is there a Time Bonus Tutorial? I haven't found one. I was wondering how I would make it so the player can get points for finishing a level under certain amount of time. For example:

If Counter <= 600 Then
TimeBonus = + 30
End IF

Or

If Counter <= 400 Then
TimeBonus = +10
End If

Counter is the variable I have for the countdown timer. And TimeBonus would be the variable for displaying the bonus points at the end of the level.

This is just sketched out and doesn't work but this is what I am aiming to figure out. If anyone could write the code in the right way that would be perfect.

Thank You
Ikonz101
User avatar
Ikonz101
Frequent Poster
 
Posts: 128
Joined: Wed Nov 28, 2007 11:23 pm

Postby reneuend » Sat Oct 03, 2009 3:34 am

It will depend on your set up, but I would do something like this.

create a procedure and place it in the Procedure area (accessed from any "advanced" tab):

Code: Select all
Function GetBonus (Time)
   
    Select Case True
        Case Time >= 20 and Time < 30
            GetBonus = 5
        Case Time >= 30 and Time < 40
            GetBonus = 10
        Case Time >=4 and Time < 80
            GetBonus = 15
        Case Time >= 80 and Time < 100
            GetBonus = 20
        Case Time >= 100 and Time < 150
            GetBonus = 30
        case Else
            GetBonus = 0
    End Select

End Function



From the code in your game where you set the bonus, call the procedure:

TotalPoints = Points + GetBonus(Points)


Note: you can set the range and bonus points to anything you want.

Hope this helps.

(edited) My mistake. I was using regular VB and not VBScript. Above procedure has been updated!
Last edited by reneuend on Sat Oct 03, 2009 5:10 pm, edited 2 times in total.
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby Ikonz101 » Sat Oct 03, 2009 8:41 am

I get a expected statement error when I put the code into the procedures.

Ikonz101
User avatar
Ikonz101
Frequent Poster
 
Posts: 128
Joined: Wed Nov 28, 2007 11:23 pm

Postby Ikonz101 » Sat Oct 03, 2009 7:35 pm

I am completely lost on this one. Do I change the Time code with Counter? Counter is my variable for time. Do I have to make a variable with GetBonus? I am not understanding this at all.

Thank You
Ikonz101
User avatar
Ikonz101
Frequent Poster
 
Posts: 128
Joined: Wed Nov 28, 2007 11:23 pm

Postby reneuend » Sat Oct 03, 2009 8:56 pm

Time is the Counter. You DO NOT need to change the procedure. But when you call the procedure, you use your counter variable.

Total Points = counter + GetBonus(counter)

GetBonus(counter) is replaced with what is returned by the procedure, which is determined by where counter (copied to the "time" variable in the GetBonus procedure) falls within the range in the Select statement.

You shouldn't be getting an Expected Statement Error. I tested it in AM.

Make sure you code it as a FUNCTION and not a SUB.
Make sure the Select statement is coded as shown, you can change the range to fit your needs though.
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby Ikonz101 » Sun Oct 04, 2009 5:53 am

I still can't get it to work. Its not showing the time bonus numbers anywhere on my screen at the end of the level. I have a Total Score that shows the total points of items collected but nothing is appearing for the time bonus. Do I need to make a text object for this to appear on the screen?

Thank You
Ikonz101
User avatar
Ikonz101
Frequent Poster
 
Posts: 128
Joined: Wed Nov 28, 2007 11:23 pm

Postby reneuend » Sun Oct 04, 2009 7:33 am

I didn't realize you wanted the time bonus to show up separately! Yes! You'll need a different text object. And then display the bonus variable for it.
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby Ikonz101 » Sun Oct 04, 2009 8:45 pm

What does GetBonus Object Not a Colletion mean? This is the code I have that shows the total amount of items taken at the end of a level in frame properties:

i = Action.GetMergedTextIndex
Text(1).Caption="Amount Taken:$ "+CStr(MYSCORE)

MyScore is the variable that displays the score

So how would I fit your code Total Points = counter + GetBonus(counter) into my code so it adds the score with the counter to be displayed as: Amount Taken: $500 + Time Bonus: 30 = Total Score: $530. (Thats what I want my final text to look like after you finish the level)

Thank You
Ikonz101
User avatar
Ikonz101
Frequent Poster
 
Posts: 128
Joined: Wed Nov 28, 2007 11:23 pm

Postby reneuend » Mon Oct 05, 2009 1:36 am

Now that I understand more clearly what you want, here is how you would do it. You'll need to have a "Bonus" and a "TotalScore" variable along with "MYSCORE".


Bonus = GetBonus(MYSCORE)
TotalScore = MYSCORE + Bonus
"Amount Taken: $" & cstr(MYSCORE) & " + Time Bonus: " & cstr(Bonus) & " = Total Score: $" & TotalScore
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby Ikonz101 » Mon Oct 05, 2009 1:54 am

YES!!! YES!!! IT WORKED!!! THANK YOU AGAIN reneuend!!! Now I am completely done with all the elements of the game for time and score. I can now concentrate on the level design.

Thanks
Ikonz101

P.S. I can make different GetBonus Procedures for each level I intent to make correct? I will have different levels with different times. So I was thinking of making a GetBonus2 and GetBonus 3 in the global procedures so it will call for the right time bonus score.
Last edited by Ikonz101 on Mon Oct 05, 2009 2:29 am, edited 1 time in total.
User avatar
Ikonz101
Frequent Poster
 
Posts: 128
Joined: Wed Nov 28, 2007 11:23 pm

Postby reneuend » Mon Oct 05, 2009 2:23 am

Glad I could help! :D

Let me put it another way. There are a lot of helpful people out here that help me out too. I'm just trying to pass it on! :wink:
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby Ikonz101 » Mon Oct 05, 2009 6:46 am

The AM community is great!! I hope to some day to be able to pass this knowledge along as well.

Thanks Again
Ikonz101
User avatar
Ikonz101
Frequent Poster
 
Posts: 128
Joined: Wed Nov 28, 2007 11:23 pm

Postby chickens1127 » Mon Oct 05, 2009 12:15 pm

NO COMPRENDO! :D
Hi... It's Chickens1127...
CHINCHILLAS ROCK!

RIP Crazygamemaker
User avatar
chickens1127
AM Magazine Moderator
 
Posts: 898
Joined: Thu Nov 22, 2007 12:49 am
Location: Awsomeville, USA

Postby Ikonz101 » Mon Oct 05, 2009 2:49 pm

What don't you understand :D

Ikonz101
User avatar
Ikonz101
Frequent Poster
 
Posts: 128
Joined: Wed Nov 28, 2007 11:23 pm


Return to Adventure Maker Technical Support and Bug Reports

Who is online

Users browsing this forum: No registered users and 0 guests