My Message close
GAME JOBS
Contents
Toward Programmer Interactivity: Writing Games In Modern Programming Languages
 
 
Printer-Friendly VersionPrinter-Friendly Version
 
Latest Jobs
spacer View All     Post a Job     RSS spacer
 
May 22, 2013
 
2K Games
Graphics Programmer - 2K Games
 
2K Games
Engine Programmer - 2K Games
 
2K Games
Tools Programmer - 2K Games
 
GREE International
Senior Product Manager, Growth and Revenue
 
GREE International
Business Intelligence Data Analyst
 
Synergy Blue
3D Artist / Animator
spacer
Latest Blogs
spacer View All     Post     RSS spacer
 
May 22, 2013
 
Using Small Studios As Stepping Stones In Your Career [2]
 
Combat Analysis: Guacamelee
 
Kickstarter Fu
 
Why every developer should play Aliens: Colonial Marines
 
Coding "To The Metal" is a dangerous ideal. [3]
spacer
About
spacer Editor-In-Chief:
Kris Graft
Blog Director:
Christian Nutt
Senior Contributing Editor:
Brandon Sheffield
News Editors:
Mike Rose, Kris Ligman
Editors-At-Large:
Leigh Alexander, Chris Morris
Advertising:
Jennifer Sulik
Recruitment:
Gina Gross
Education:
Gillian Crowley
 
Contact Gamasutra
 
Report a Problem
 
Submit News
 
Comment Guidelines
Sponsor
Features
  Toward Programmer Interactivity: Writing Games In Modern Programming Languages
by James Hague [Programming]
Post A Comment Share on Twitter Share on Facebook RSS
 
 
August 13, 1999 Article Start Page 1 of 4 Next
 

What's the most productive way to spend the next month? You could write three or four short stories for The New Yorker. You could pen maybe half the songs for your next album. You could devote three hours each morning to updating your popular game-related news site. Or you could continue debugging the unit AI for your up-and-coming real-time strategy game, which will put you close to a third of the way toward getting behavior that won't look blatantly stupid to the average Wal-Mart shopper.

Let's face it: game programming is hard. And it's easy to be jealous of those other guys.



That's not to say that writing songs or fiction is easy, but you're not going to see an author throw up his hands and say, "The technical problems involved in writing a story about a mermaid are going to take me six weeks to solve." Or "I've written this brilliant essay, but I'm having the hardest time keeping the characters from constantly walking into each other."

Writing and debugging code in Visual C++ doesn't have nearly the same easy flow as editing and revising paragraphs in Word. Quick: You have thirty seconds to compute the value of "sin(0.43) * 1.8" without using a calculator! (30 second pause.) Odds are that you're sitting in front of hugely powerful computer, and yet you didn't have an easy way to get at the answer. There's no sine key on the Windows calculator. And could you have created a Visual C++ project and written code to display the result in less than thirty seconds? Something isn't at all right with this picture.

Let's jump off into a caffeine-induced fantasy-land for a minute, and pretend we have a magical system that makes programming be fantastically straightfoward.

First, we dispense with our math problem by typing it in directly:

sin(0.43) * 1.8

and we get an answer back right away:

1.227597

Well, shoot, a Commodore 64 could have done that! Let's write some basic vector functions:

magnitude (x,y,z) = sqrt(x*x + y*y + z*z)

dot (x1,y1,y2) (x2,y2,z2) = x1*x2 + y1*y2 + z1*z2

normalize (x,y,z) = (x*m, y*m, z*m) where m = 1.0 / magnitude(x,y,z)

Now let's test these out (the first line of each pair is our query; the second is the result):

magnitude(10,20,30)
37.416574

normalize(10,20,30)
(0.2672612, 0.5345225, 0.8017637)

normalize(1,0,0)
(1,0,0)

(1,0,0) `dot` (0,1,0)
0

We're already getting interesting results. Obviously, a unit vector is, by definition, already normalized, but it's nice to be able to quickly verify that. It also looks like a unit vector dotted with an orthogonal unit vector gives a result of zero. We haven't proven it, but it's an interesting theory nonetheless. This is amazing! Three lines of "code" and we're learning properties of vector math.

Even more amazing is that we aren't in fantasy land at all. This is real code, written in a real programming language (not just a math package) with existing compilers that generate machine code. You can be doing the same thing on your Windows, Linux, or MacOS machine within a few minutes. For free.

 
Article Start Page 1 of 4 Next
 
Top Stories

image
Xbox One is Microsoft's biggest play for living room domination
image
Opinion: Xbox One is a desperate prayer to stop time
image
Indies on Xbone: Where's the beef?
image
'If you're backwards compatible, you're really backwards.'
Comments


none
 
Comment:
 




UBM Tech