Brain Academy?

BlitzMax Forums/BlitzMax Programming/Brain Academy?

Ash_UK(Posted 2007) [#1]
Hi guys :o) I was wondering if someone could help me, I would like to create a Math game like the one in Nintendo's "Big Brain Academy"
For those that don't know, in the game you are given a random total to sum up using various numbers:



As you can see in the pic above, you have 5 blocks with numbers on. Some of them will add up to the total given (the number is 12 in this example) and others will not. You must whack away any of the numbers that don't belong there (Numbers 1 & 2 in this case) :o)

If anyone could please help me figure out how to code something like this, I would be ever so grateful. Some example code would very much appreciated too if possible :o)

Thanks guys. Take care!


Jesse(Posted 2007) [#2]
I think this post is better started in beginners area.

you need to let us know about how much programming you know and if you have made an effort on starting it on your own. no one is going to make your game for you and doubt if anyone has the time. besides you won't learn much if you just copy/paste code from others. that is a really simple game to make and should be a great start for a beginner. I will give you some simple commands you should know how to use before you start:.
graphics() 'obiously
loadimage()
loadimagefont()/setimagefont()
drawimage()
showmouse()/hidemouse()
mousex()/mousey()
rand()
drawtext()
keydown()/keyhit()
while/wend, repeat/until

more basic programming
(arrays of images) 'not necessary but is one of the more obious alternatives
math to determine if mouse is within range of specific tiled image.

I will give you a rundown of what you need to do:

first you need to set your graphics mode
load all images. looks like you are going to need a graphic image for each of the numbers. if you want to use text fonts for the answers then you are going to need to load different size fonts. If you use images for the answers, I don't recommend(uses a lot of Ram) but is your option.

figure out how to and what order your numbers are going to be displayed and do it.
loop:
once your screen is set check for user mouse input. determine if mouse is within range of number with mousex & mousey. and determine if mouse button was pressed with mousehit. compare values selected with correct answer. display output based on answer.
loop end

note:
try having two images for each number one non-hilited and one hilited for when a number is selecter. display acordingly and keep track of numbers selected.

I am sorry if you know more than I am assuming but being this such a simple game I am assuming you are really green :-).
I am definitely not a game expert and my explanation may not be the best. I have made a couple of games and that is the way I would have made it if I was starting out.

don't give up. just about everyone is willing to help if you just ask specific questions and if you show some effort.
I can help you directly, when I can if you email me with sample code. I have time randomly during the week so it might take me up to two to three days to answer you so if you are willing I am there.


Ash_UK(Posted 2007) [#3]
Sorry Jesse, I should have been much more specific about what it was I was asking for. With respect, I am most certainly not green when it comes to programming :o) I know all of the basic programming such as setting up graphics, detecting the mouse position etc etc. the thing that is troubling me is me is the actual calculating of a random sum. For example I would just like to know how to do the following:

1. CPU generates a random total, for example the number 18.

2. CPU then generates some random numbers such as 9, 5, 4, 9 & 2. Some of the numbers will add up and others will not. Obviously the correct numbers to keep here would be 9 & 9. You would whack away the numbers 5, 4 & 2 to finish the task.

3. Repeat step 1

Thank you for your co-operation Jesse, it is very much appreciated :o)


Brucey(Posted 2007) [#4]
Why go about it backwards ?

Wouldn't it rather be better (ie. simpler) to generate a set of random numbers and pick some from the list to come up with a total ?

And btw, from your 2) wouldn't I also be able to choose 9, 5 & 4 to get my answer of 18 ? :-p


Jesse(Posted 2007) [#5]
this code sets the first three nubers = the answer:
Strict
SeedRnd MilliSecs()
Local total = 9+Rand(10)
Local i% 
Local n[5]
Local sum = 0
For i = 0 To 2 
	Repeat 
		n[i] = Rand(total/2)
	Until n[i] > 0
	If (sum + n[i]) > total Or (i = 2 And (n[i]+sum) < total)
		n[i] = total - sum
	EndIf
	sum = sum+n[i]
Next
n[3] = Rand(9)
n[4] = Rand(9)
i = Rand(4)
Print total
n.sort()
For i = 0 To 4
	Print i+" "+n[i] 
Next

the first three numbers are the answer. the last two numbers are just random numbers generated. it is all just a matter of what order you display them.
note that even the last two numbers can generate a valid answer but all you need to do is add the numbers left compare them to the answer and you have your valid comparison. you will have at least one valid set of numbers


Ash_UK(Posted 2007) [#6]
Thanks very much Jesse, I really appreciate your help :o) and thank you Brucey also. You have both been very been helpful. Take care guys!