swordprototype.zip 47.71 KB
made with vc#2k3, so make sure you've got the .net runtimes before you try to run it. oh, and it uses mdx9 for the joystick interface. i'm guessing there ain't too many people that'll even bother with it ^_^
[edit: hotlinked some of the interesting trackbacks.. notepad don't do that for me!]
[edit: updated exe with crappy try/catch block so the thing isn't as ugly as 'unhandled exception' dumps]
[edit: hmm still dumps on craig's compy.. maybe he doesn't have the mdx runtimes?]
- 2006/05/10 -
whoever invented date ordering is fucked. it should be year, month, day. things are arranged better in my folders that way.
lol i just read a gamasutra article i found on the [gdnet forums > gdnet contest] thread, found here: http://www.gamasutra.com/features/20051026/gabler_01.shtml . alot of the stuff i felt i already knew, but having it put in my face again was refreshing. some of the stuff i learned was really just direction - the most important thing i pulled out was that i need to prototype before i try entire projects.
sounds obvious, huh? so where'd i miss that bulletin? anyways it got me to thinking, what projects am i not doing anything on that i want to... a ton, that's for sure! one of the simpler ones was goign to be dragon warrior. but as i thought more and more about it, the game merited different designs, some seemed to make more sense to use than others. for instance, if i was only going to ever have one monster battling you at a time, why would i bother letting the player face in any direction other than the monster? why would you turn your back or side to it? i suppose that in certain situations you might want to hit it in the back or something, depending on the monster defeat mechanism for the particular monster..
anyways, i digress. as i thought on it i realized -- why aren't i making prototypes of these ideas? some of my gameplay ideas are 2d, i don't need a fancy sprite engine for that; i can use basic forms stuff to do it. i just need a playing field and some sprites, the window background and a few (one?) picturebox will do fine for that. thinking ahead, i could even do that zelda bow&arrow idea this way as a prototype if i were so inclined in the future!
now i will chronicle my prototyping efforts! its 3:21pm and i gotta start getting ready at 8pm for work. thats a little less than 5 hours. i should be able to get this prototyped and be able to play it by then for sure. let's see how well i can deal with distractions!
-- prototype design begin --
so what is it i'm prototyping? well, one of the possible control schemes i had in mind for a zelda clone was a dual analog kinda thing. something like loaded/reloaded or smash tv, you use the left analog to move, and the right analog to face your player. pressing some other button would shoot, but this is gonna be zelda, so we'll have him swing his sword.
i've done this sort of thing once before, it wasn't hard. i think it was a smiley face that had a crosshair cursor that would move around the face and when you pressed the shoulder button you'd make a bullet fly in that direction. there'd be a target somewhere random and the point was to get as many as you could in the time you had.
i'm not aiming for any kind of game here, i just want to see how well this kind of control scheme could work for melee battle.
the idea is to use the left analog to move link around (we'll use the gameboy sprite set for simplicity's sake - plus i like it ^_^) and the right analog will aim link for his attack. when you press R1 he'll swing his sword through an arc - i might need a slider or something to allow for different arcs for testing. there'll also be a slime moving around at random that you can attack. already i'm thinking about having the slime do two different kinds of ai, but i should save that for a different prototype. he'll just slide around and thats it. no, even better, we'll just not have him move at all. put him in the animation and just have him sit there.
we'll detect whether link hits or not, and put a message up every time he attacks that says whether there was a hit or not. we might want to draw the boundtest regions over the sprites.. can i do that? maybe two sets of sprites then.. and have a checkbox that lets you turn them on and off.
i'm probably going to need to draw a line from the center of link and out to represent where the right analog is being pushed, so you can have a better guess at where you're going to attack. we'll start with a 90' arc like he gets in Z:LA and let him attack in 8 directions instead of just 4.
when the player pushes the right analog, we should face link in the direction that matches it best - but we'll only have 4 facing dirs so it won't look as great. its good enough.
i'm going to do alot of hardcoding and dirty stuff, prototyping means just getting something up and thats it. its by no means an end product. i just wanna see what it looks like.
-- production begin --
ok lets start with our project. basic windows form in c#. let's get some coding music going.
[now listening to: guitly gear music folder]
crap my coffee is empty and my tummy's acidy. i need some coding snacks. forget it for now.
first thing's first, i'm gonna add a groupbox (playAreaGroupBox) so i can set aside some of the space for any controls i might want to add. gotta lock the window to a fixed size, don't want to deal with people screwing with that. throw down a picture box for link (playerPictureBox), and one for the sword (swordPictureBox).
ok now we need to make and add some pictures to the resources for stuff. i need 4 standing pics of link, and 8 sword pics for each angle. gonna need to make 'em first. [ripping/drawing] hmm looks like i still have some stuff from when i was doing mockups. sword's done, i just need link in all 4 dirs [looking] hmm i have E and W but no N and S. easy enough to get. [working] ok now to break up the sword bmp [working] cool, done. lets grab our mockup background and set it to the groupbox background. [working] slapping some graphics on our two pictureboxes, stretching them to doublesize, and doublesizing the background image - just too small! [working] hmm setting map as groupbox bg is just too ugly. adding another bmp and pushing to back. [working]
ok now we need to set up the game loop and timing stuff. [working] hmm i can't seem to get Utility.Timer(DirectXTimer.GetElapsedTime) going. what reference am i missing? i got ms.dx in there.. [looking on msdn] argh, i'm not sure what reference i need to use the code.. i poached it from mdx9 kickstart, but looks like i gotta do it manually, with Sys.Env.TickCount. [working]
ok i think i got the main loop and logic timing set up. now lets get some joystick input and move link around. crap, a vector class would be keen. i wonder if directx's vector will do the job? let's get the joystick in. [working] got dx.di ref added in, and using clause. added an Init() routine, we'll set up the joystick in here. [working] holy crap he moves fast! gonna need to slow that down. [working] there we go. now we can face the bugger.
-- breaktime --
crap its like 6 now! ugh my tummy needs food. food break! [fooding] mmm cookies.. added a label on the right, to show what the space is for.. [fooding] next thing i should do is get rid of the purple background of the sprites.. probably gonna need to go to gif for the translucency. [fooding] mmm triple decker pb sammich (and milk!!).. crap i'm getting crumbs in my book. someone should do a survey about what kinda power lunches people eat while they're coding. [naptime!]
filled my tummy, and took a nap. now its almost worktime. gonna set up for the next step, right analog. this one isn't as easy as the last one was, because i don't remember what the two axes are. i think it might have been Z and Rz but i'm not sure. do i still have the shooter thing? [looking] yup, there it is. the (x,y) pair for the right analog is (z,rz). good to know.
- 2006/05/12 -
back to the grind. i've got 4 hours this time. i had a hard time getting the drive to come back, but i was thinking about children of mana and it got me going.
so we're going to get the right analog and use it to choose a new direction for the player. pretty easy, get a vector, and check what direction is biggest. that'll tell us which sprite to use. [working] well now, there's a mystery. i need to figure out which direction has the most on it, but wait, its just two axes i need to compare, huh? well thats way easier. [working] its dirty, and i'd say we'd more likely be taking the vector's angle and using that to pick from a sprite set. meh. [working]
ok i'm set to pick, but i don't have any pics in the resources to choose from yet. time to slap them in there. gonna have to read about that, first. probably winforms book will help me best. [looking] hmm he spells it out pretty much for me. [working] or does he? seems he doesn't tell me how to do what i'm trying to do. just a bunch of shit about culture and resx files. he tells me how to add a resource and how to get it to build as embedded, but then he doesn't tell me how to get it out and use it. fucker. guess i can't really build anything this complicated with embedded shit. i could load the stuff from file i guess but i'm feeling defeated and giving up. cockfags.
huh? olu pointed me at http://www.jelovic.com/articles/resources_in_visual_studio.htm - i'm gonna give it a shot. [working] huh, that did the job alright! the last little thingy at the bottom was what i used. funny that it's using the N image for up and down.. hmm [working] oh, i was checking the leftAnalog by mistake. fixed. and there we go, now i have the right analog facing the fecking player. bleh. looks like vs.net still needs work on the resources part. screw it, i have a working solution.
ok now we got link running around and facing, now we add the swordy! so first we detect the button press. [working] R1 maps to button 7. [working] ok, so we know we're arcing over 90deg only. we need to do it over some period of time, of which each of 3 images will be displayed and positioned. i'll have to do this with an angle variable. [working] only thing left to figure out is where to drop the sword picture. take the right analog, snap it to a 45 and extend it to the size of the player bmp. then slap it wherever that is, relative to th player. [working]
argh so close! the angles are coming up wrong though, and the pictures are exactly opposite! if i hold to the right and attack, the starting value should be 45degrees. heh turns out originally i was having such trouble because i wasn't converting radians to and from degrees.. oops! so whats the problem NOW. [looking] lol i flipped the reposition Y to negative and the pictures are being shown right! but now if you face up and attack, the sword comes out of your ass! the left and right works perfect, i just gotta figure out.. should i give tan2 a negative y? [checking] lol yeah.. stupid worldspace vs screenspace.. negate those Y values, dammit! but there. i should be able to compile a release ver and have a fully standalone test prog. [checking] yup, it works fine. gonna want to get rid of that purple shit and speed up the sword a little more. [working]
seems there was a problem i had in my mind before.. something about what happens when you're not directing the right analog and you attack.. if its a problem it'll crash or the bug will appear sometime. anyhow, yummy prototype! [testing]
hmm, it won't do transparency for some reason. oh well, i'll deal. my default control isn't as glaring as purple is. ^_^ its good enough to release for now. whee!
to try later:
- if right analog not being used, left analog should change direction
- look at adding targetting cursor or something, you can't tell where you're aiming right now