Hangbot - Asimov Testgame
Posted: June 29th, 2013, 11:11 am
Hi all,
This is my first WIP of my game Hangbot. I have had some spectacular crashes and freezes, so be warned before you try out the code. I think I have got it stable now. I think the crashes were because I was trying to free memory already free.
Ok all this will do is show a menu. If you press key 1 a pile of letters come up. When you press a letter on your keyboard a letter should disappear from the screen.
Now this is painfully slow in debug, faster in release, but super fast if you just run the release exe after. I know my keyboard routine is not the best, and I should be using directinput or something, but I haven't got my head around the complexities yet.
Here is my current keyboard routine which returns a letter if pressed. I am using GetAsyncKeyState which can be quite slow at times. Yes I know I need to replace this with a better routine, but I am trying to learn as I go. It is hard without following a chilli tutorial LOL.
This is my first WIP of my game Hangbot. I have had some spectacular crashes and freezes, so be warned before you try out the code. I think I have got it stable now. I think the crashes were because I was trying to free memory already free.
Ok all this will do is show a menu. If you press key 1 a pile of letters come up. When you press a letter on your keyboard a letter should disappear from the screen.
Now this is painfully slow in debug, faster in release, but super fast if you just run the release exe after. I know my keyboard routine is not the best, and I should be using directinput or something, but I haven't got my head around the complexities yet.
Here is my current keyboard routine which returns a letter if pressed. I am using GetAsyncKeyState which can be quite slow at times. Yes I know I need to replace this with a better routine, but I am trying to learn as I go. It is hard without following a chilli tutorial LOL.
Code: Select all
#include "keyboardinput.h"
keyBoard::keyBoard()
{
textreturn[0]=L"A";
textreturn[1]=L"B";
textreturn[2]=L"C";
textreturn[3]=L"D";
textreturn[4]=L"E";
textreturn[5]=L"F";
textreturn[6]=L"G";
textreturn[7]=L"H";
textreturn[8]=L"I";
textreturn[9]=L"J";
textreturn[10]=L"K";
textreturn[11]=L"L";
textreturn[12]=L"M";
textreturn[13]=L"N";
textreturn[14]=L"O";
textreturn[15]=L"P";
textreturn[16]=L"Q";
textreturn[17]=L"R";
textreturn[18]=L"S";
textreturn[19]=L"T";
textreturn[20]=L"U";
textreturn[21]=L"V";
textreturn[22]=L"W";
textreturn[23]=L"X";
textreturn[24]=L"Y";
textreturn[25]=L"Z";
}
wstring keyBoard::key()
{
char i;
for(i=65;i<91;i++){
if(GetAsyncKeyState(i)){
return textreturn[i-65];
}
}
return L"";
}