Needed: Calculator Plugin

This forum is meant for announcing new plugins, downloading other people's plugins, posting questions, etc.

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

Needed: Calculator Plugin

Postby JasonMc » Wed Jul 07, 2010 8:27 pm

For an upcoming MousePaw Games production (starting in September 2010), I need a calculator in the game. The game is math-themed, and I want kids to be able to get help with basic calculations through the game.

The calculator would need to have addition, subtraction, multiplication, and division functions, a clear function, and memory.

I'd build it myself, but between learning the program (and VBScript) and programming our first game, I can't scrape up the time. (We only have three-month production periods.)

Hopefully, I will eventually be able to start building plugins, once I have more time and know what I'm doing.

(And, I will be sure to give appropriate credit for all plugins I use in the game credits.)

Thanks!
-Jason McDonald
Manager, Programmer
MousePaw Games

--
PocketWatch 1.0 Plugin now available in the Plugins Corner!
User avatar
JasonMc
Active Member
 
Posts: 99
Joined: Sun Jul 04, 2010 10:27 pm
Location: Pacific Northwest, USA

Postby reneuend » Wed Jul 07, 2010 10:59 pm

Hi Jason,

I don't think you need a plugin to make a calculator. I would just build the necessary hotspots to represent the keys on a calculator and then write the code behind it. How is the calculator being integrated in the game? I wouldn't think you would want just a basic calculator when it is already available in numerous forms.
---


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

Postby Lyberodoggy » Thu Jul 08, 2010 8:42 pm

you can use the openexefileandwait to open the ms calculator...
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby JasonMc » Thu Jul 08, 2010 9:04 pm

I need to actually have the game in the interface, as I'm putting the game in full-screen 640x480 format.

Thanks for the suggestions. Does anyone know where I can find a guide to writing the code for the calculator. Again, I'm very inexperienced with VBScript.
-Jason McDonald
Manager, Programmer
MousePaw Games

--
PocketWatch 1.0 Plugin now available in the Plugins Corner!
User avatar
JasonMc
Active Member
 
Posts: 99
Joined: Sun Jul 04, 2010 10:27 pm
Location: Pacific Northwest, USA

Postby Mystery » Thu Jul 08, 2010 10:23 pm

I'm not very good with VBScript, but there is a calculator on a website written in VBScript. If you check the page source code, it might help to get you (or somebody who is willing to write a calculator script) started:
http://panamarentbybarrow.com/kms/html/vbscriptcal.htm
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby reneuend » Fri Jul 09, 2010 1:44 am

Depending on how sophisticated you want the calculator it could be very simple to quite complex.

The simple method:
In this case, I didn't allow real numbers (integers only)
Each button on the calculator would be a hotspot. When the player clicks the hotspot, save the value to a string variable. As long as the player is clicking number hotspots, keep building the string variable:

example: sValue1 = sValue1 & "3" (if the player clicks on the hotspot showing a 3)

When the player clicks on an operator, then you could save the operator to a different string variable. sOperator = "+"

Now the player clicks numbers again and you'll save the value to another string variable:

example: sValue2 = sValue2 & "6" (if the player clicks on the hotspot showing a 6)


To keep this simple, I would not allow any more values or operators except for the equals sign. So if the player clicks on an operator other than the equals sign, then just ignore it. You might want to track the size of the sValue strings also. Since this is a simple calculator, maybe only allow 2 digits.

Once the player clicks on the equals hotspot, then you can add the values with the following code:

select case (sOperator)
case "+"
sAnswer = cstr(cint(sValue1) + cint(sValue2))
case "-"
sAnswer = cstr(cint(sValue1) - cint(sValue2))
case "x"
sAnswer = cstr(cint(sValue1) * cint(sValue2) )
case "/"
if sValue2 <> "0" then
sAnswer = cstr(cint(sValue1) / cint(sValue2))
else
sAnswer = "Error: Division by zero"
end if
end select

'Display the answer and clear out sValue1, sValue2, sOperator
---


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

Postby JasonMc » Fri Jul 09, 2010 8:28 pm

Thanks, reneuend! I'll try that out.
-Jason McDonald
Manager, Programmer
MousePaw Games

--
PocketWatch 1.0 Plugin now available in the Plugins Corner!
User avatar
JasonMc
Active Member
 
Posts: 99
Joined: Sun Jul 04, 2010 10:27 pm
Location: Pacific Northwest, USA


Return to The Plugins Corner

Who is online

Users browsing this forum: No registered users and 1 guest

cron