Everything I know about games I learned from the 90s
me
- digitalicarus in cyberspace, Adam Horton in meatspace
- Native Oklahoman
- Raised on Nintendo
- Hacking enthusiast/amateur
- Engineer / web developer by day
- I play the vidya games
Prologue
-
Why the 90s? New millennium not extreme enough?!
-
A system fraught with limits
-
Magick, lore, wisdom
-
Casting some spells
-
Oddities - you can't do this with that!
Awkward Ubiquity
x86 was a limited platform borne out of business machines... but it was EVERYWHERE
Why the 90s?
Novel Distribution
Shareware - a new distribution model
Why the 90s?
Opening the Guild
Programming is not a zero-sum game. Teaching something to a fellow programmer doesn't take it away from you.~ John Carmack's forward in Michael Abrash's Graphics Programming Black Book
The architecture of Quake, and most of the technology discussed in these articles, is the creation of John Carmack. John, I figure that making this freely available is the form of "thank-you" that would mean the most to you.~Michael Abrash on open sourcing the Black Book
Working with John was like the sequence in "The Matrix" where Neo has one martial art after another pumped into his brain.~ Michael Abrash http://blogs.valvesoftware.com/abrash/valve-how-i-got-here-what-its-like-and-what-im-doing-2/
... if knowledge is power, then anyone who restricts your access to the information you need to create a high-quality game is really restricting your power and ability to create your vision.~Mark DeLoura Game Programming Gems Vol 3
Why the 90s?
Limitation Breeds Creativity
- HTML 5 is a contrained platform, especially on mobile.
- There's a lot of FUD (Why mobile webapps are slow)
- The Building of Fastbook
- Is HTML5 a "valid" platform for popular games?
A system fraught with limits
Games, ah... uh... find a way
A system fraught with limits
pdp-1 1962, Tennis for 2 Donner Model 3 1958 analog
Games, ah... uh... find a way
A system fraught with limits
pdp-10 1975
Games, ah... uh... find a way
A system fraught with limits
ti-89 series introduced in 1998
Games, ah... uh... find a way
A system fraught with limits
lotus 123, IBM PC first "killer app" - 1983 PC/DOS games sucked compared to computers aimed at consumers (amiga, atari, MSX, etc)
Games, ah... uh... find a way
A system fraught with limits
Tomes of great power
Magick, lore, wisdom
Midpoint Displacement
Magick, lore, wisdom
Midpoint Displacement
Casting some spells
Learnin' from the Lander
- Read = know, Code = grok; Grok > Know
- There's the first 90% and the second 90%
- Most learning happens in second 90%
- Finishing small things completely more times > few large things?
Casting some spells
Raycasting
Magick, lore, wisdom
Raycasting - casting a ray (Permadi)
- find first horizontal grid intersection by solving the triangle
- figure out if going up||down (down is +!)
- check first horiz grid for hit, keep incrementing until hit or out of bounds
- repeat above for vertical intersections, but sideways :)
- horizHitDist < vertHitDist?
- mark hit tile and texture offset
Casting some spells
Raycasting - cast data
var rayInfo = [{
dist: 42, // the ray distance
horizHit: true,
vertHit: false,
horizDist: 42,
vertDist: Infinity // or undefined?
tile: 3,
offset: 12, // which vertical strip of texture to sample
}];
Casting some spells
Raycasting - cast sweep
var fov = deg2rad(60)
, numstrips = xres / stripwidth
, numrays = numstrips
, rayincr = fovrad / numstrips
;
// cast rays
for (i = player.angle - fovrad/2; i < player.angle + fovrad/2; i += rayincr) {
rayInfo.push(cast(player.pos, i));
}
// draw
ctx.lineWidth = stripWidth;
for (i = 0; i < numStrips; i++) {
ctx.beginPath();
ctx.moveTo(
i * stripwidth, // x position
(yres/2) - (rayInfo[i].dist*scalefactor/2), // canvas center - 1/2 strip height
);
ctx.lineTo(
i * stripwidth,
(yres/2) + (rayInfo[i].dist*scalefactor/2), // canvas center + 1/2 strip height
);
ctx.stroke();
ctx.endPath();
}
Casting some spells
Concludin' from the Caster
- Use the timeline/profiler luke (stay on target - lose porkins)
- Var'ing 120*2*60 per second is expensive :)
- Performance computing is an exercise in cacheing
- try/catch isn't so expensive - always running code is
- Really high performance JS looks kinda like C, makes Crockford ಠ_ಠ
- Hinting high perf code cuts like a knife, but it still feels so right
- Raycasting isn't just for display (other vision, audio)
Coerce to boolean: !!var
Truncate to integer: ~~, |, >>0
Capitalize: str.charAt(0).toUpperCase() + str.slice(1)
Casting some spells
Detours - yes, have some
- Apple Floppy Copy
- Evercookie
- Pointer arithmetic for mathematics - Abrash
- clippy.js "We built clippy.js over the weekend to remind people to try risky and silly things"
Oddities - you can't do this with that!
Epilogue
- Assume nothing - measure
- Know your toolkit (links!)
- Study the lore and artifacts of the past
- Read old books
- Play old games (System Shock, Thief, Quake, Deus Ex)
- Repeat old experiments
- Use tools for unintended purposes (what does this really do?)
- Do things for fun or just to see if you can
Acknowledgement
- Generating Random Fractal Terrain - Paul Martz
- Permadi's Raycasting Tutorial
- Lodev's Raycasting Tutorial
- Black Art of 3D Game Programming - LaMothe
- Gardens of Imagination - Lampton
- Graphics Programming Black Book - Abrash
- Game Programming Gems
- One Game a Month
- Why mobile web apps are slow - Sealed Abstract