# Graph wars

This topic is 2169 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am a high school math teacher, and I want to create a custom "graph wars" game for competitions where the screen has 4 quadrants along with obstacles and targets to hit by typing in mathematical functions.  I have previously had a little C programming and Java programming instruction but its been a while.  What language would you recommend I try to code this in?  Graphics do not need to to be too advanced, and I would also prefer a nice easy learning curve so I could do this on my own.  Thanks!

##### Share on other sites

Look towards C# and .NET (which is basically Java done right!). Most of what you'll need for basic drawing can be found in The System.Drawing namespace, see here: http://msdn.microsoft.com/en-us/library/system.drawing.aspx for the reference documentation, and I'm sure you'll find some

Alternatively, you could use the Tao framework if you'd prefer to use OpenGL, or XNA if you want to go down the D3D route.

It's relatively trivial to utilise the WYSIWYG GUI editors found in Visual Studio 2012 Express Edition (which is free), to quickly knock up fairly professional looking GUI's with a minimum amount of fuss. I'd probably recommend finding a good book on C# and .NET (although I don't have any recommendations myself - I'm sure others can help out here), and you should be up and running in no time!

##### Share on other sites

I would say to use python, the reason is that it has the build in function called eval, so you just get the input as a string and call:

x = 0
y = eval (<input string here>)


You can iterate it from some values and you will have all the values you need to plot in a graph. You can use pygame to plot the graph, it is a very simple 2d graphic engine.

Here is a simple example that will print 100 values of (x, y) for the expression x^2 + 1, from -10 to 10:

expression = 'x**2 + 1'
numberOfPoints = 100
start = -10
end = 10
step = (float(end) - float(start))/float(numberOfPoints)
pointsToPlot = []
for i in range(numberOfPoints):
x = start + step*i
y = eval(expression)
pointsToPlot.append((x, y))

for i in pointsToPlot:
print i


Off topic:

Look towards C# and .NET (which is basically Java done right!).

Incoming flame war...

Edited by KnolanCross

##### Share on other sites
I'm not personally fond of Java, but it would make sense for this job. You have already used it, it's multiplatform, and standard Java libraries are enough for any drawing you need.

Basic drawing is this easy:
http://www.zetcode.com/gfx/java2d/basicdrawing/

A quick google for "Java graphing", "Java calculator" etc. brings up a ton of Java apps like this one which also have source code available, so you can see how they did things.
http://sourceforge.net/projects/funcplotter/

##### Share on other sites

Going with a language you already know is probably your best bet. If you don't want to do straight Java, I'd recommend you look at Processing. It's fairly easy to learn, especially if you already know some programming. And there are graphing libraries you can use, like gicenterUtils and gwoptics.

Processing: http://processing.org/

gicenterUtils: http://www.gicentre.org/utils/

• 21
• 11
• 9
• 17
• 13
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!