Jump to content
  • Advertisement

cornflake

Member
  • Content Count

    62
  • Joined

  • Last visited

Community Reputation

150 Neutral

About cornflake

  • Rank
    Member
  1. cornflake

    is this enough. and a question on gimp

    Quote:Original post by Scet please just Google for Gimp. Sorry, couldn't resist, you should probably add "image manipulation" or "image editor" to your search. I'm not sure how highly Gimp comes in google ratings, so Googling for just "gimp" may produce some rather interesting results.
  2. cornflake

    Question about * usage (pointers?)

    EDIT: Nobodynews, just saw your post, I think that's probably the issue. Quote:Original post by Scet POTION* potionlist[15]; This is an array of 15 pointers to POTION structs. Quote: as in the pointer tutorial it didn't have things with the asterix on the end of a word like this. Are you sure? That's how pointers are declared, it would be hard to do a pointer tutorial without the * operator. It did have the * operator, but not used in the way above. I'll re-read through the bit on pointers to arrays, and see if I can find another tutorial as well, as lookig at the source I think I need to make sure I understand pointers fully. The examples for declaring pointers were - int * number; char * character; float * greatnumber;
  3. I'm looking through some code examples, and although I've been working through a C++ tutorial and think I've got the hang of pointers I've come across something I don't understand. The code I'm looking at is a player class from the Wrathlands source - class PLAYER: public ENTITY { private: int strength; int intelligence; int level; WEAPON weapon; ARMOR armor; POTION* potionlist[15]; SPELL* spelllist[10]; public: PLAYER(); void SetStrength(int newstr); int GetStrength(); void SetIntelligence(int newint); int GetIntelligence(); void SetLevel(int newlevel); int GetLevel(); WEAPON* GetWeapon(); void SetWeapon(WEAPON weapon); ARMOR* GetArmor(); void SetArmor(ARMOR armor); void AddPotion(POTION* potion); POTION** GetPotionList(); void AddSpell(SPELL* newspell); SPELL** GetSpellList(); void CheckForLevelUp(); }; What I don't get is the lines like POTION* potionlist[15]; as in the pointer tutorial it didn't have things with the asterix on the end of a word like this. Can someone explain what this does? It may weel be something I haven't covered yet but I'm trying to follow the things I learn in examples like this so I can relate what I learn to real world uses, as this helps me learn things a lot better.
  4. cornflake

    Hi from a newbie

    Quote:Original post by CzarKirk I don't see how you can have 2.5 girls. All of them are girls. Half are girls, so are the other half.
  5. cornflake

    Beginner's guide to AI?

    I have a copy of Tricks of the Windows Game Programming Gurus (2nd Ed) and the AI section in there is very good for a beginner IMHO. I found it very interesting, and gave me a few ideas about things that I could then go and research more on the web. I'm not sure about any other books purely on AI, as said above Amazon would be good as you can read reviews etc and get an idea of how they would be for a beginner. If you find any good stuff online maybe post them here as I remember having some trouble finding anything good as well
  6. cornflake

    Hi from a newbie

    Quote:Original post by cNoob Welcome back cornflake. If its just text based programs your wanting to write, then you wont be needing the platform SDK. Just run the ee setup and you'll be ready to create console apps without the need of any other files or librarys. Is it Win32 Console Application I should choose? It seems to add some reference files as default and I'm not sure about adding iostream (I'm trying to follow an online tutorial so I just want a blank project really plus the includes).
  7. cornflake

    Hi from a newbie

    Quote:Original post by BCullis Quote:Original post by cornflake A man has five daughters, half are girls. How is this possible? Also, any recommendations for setting up Visual C++ Express for learning C++ and writing games? 1) Half are girls because you don't explicitly state the other half aren't girls ("I have 6 apple pies. 3 of them are pies.")? 2) I just downloaded and ran the install for Visual C++ Express 2005 direct from the Microsoft website, so I'm not sure what in particular you're looking for as far as setup tips go. 1) Spot on, that one took my wife about an hour. 2) I wondered if there were any specific things to set up in the configuration before I start programming but I've now found several posts about the platform SDK etc so I'll follow the instructions there.
  8. cornflake

    Hi from a newbie

    Quote:Original post by boldyman No question? www.nextdawn.nl www.moneyaside.com You want a question? I was just saying hi, but you can have a question if you want :) A man has five daughters, half are girls. How is this possible? Also, any recommendations for setting up Visual C++ Express for learning C++ and writing games?
  9. cornflake

    Hi from a newbie

    hi, I spent some time on here a while ago, then left but I'm back now. I didn't get that far but I'm hoping to get further this time. I've done quite a bit of VB.NET stuff and did Pascal years ago at college. I work full time in IT Support and have started doing work in IT security recently (which is scary when you find out what people can do, believe me!) I plan to start by learning C++ using mainly Visual C++ Express Edition. I'd also like to get into some Assembly language. I'm mainly interested in playing around with AI, neural nets etc rather than the fancy graphics side of things. My first game project is probably going to be mainly text-based as last time I found even a basic pong or tetris clone was a challenge so I know I need to start simple. Other hobbies for anyone who's interested are model rocketry and photography.
  10. cornflake

    Please critique my first game!

    Quote:Original post by SteelGolem no, i think hattan means that when you look at the code, you shouldn't have any labels named label1 unless you're never going to reference it. [edit: try using more descriptive names] This is an important point. You really do need to get in the habit of desctiptively naming EVERYTHING if you are going to use .NET, especially if you use Visual Studio, where you're just dropping new controls etc all over the place. My first app in VB/ASP.NET is now 75 files and it is a nightmare to debug or change anything. I used naming conventions in my second one and it is so much easier. Look here for a good naming standard - http://www.ssw.com.au/SSW/Standards/DeveloperDotNet/DotNetStandard_ObjectNaming.aspx
  11. cornflake

    GDI issues again!

    1) You're right - I don;t have a lot of knowledge 2) I try to copy-and-paste code as little as possible, and only when I understand what it does. The original program was from an example which I understood, but it only drew things in the main event loop. I am now trying to draw everything in the Game_Init, Game_Main functions as I understand this is where it should be done. The HWND hwnd; line is ther ebecause before I put it there the code wouldn;t compile, saying 'hwnd' not initialised or something similar. Evidently this is the wrong way to correct this problem, but I still don't see how to get the drawing to work in the Game_Init or Game_Main without WM_PAINT overwriting. And I understand you don't want to just give me code to do it, so hints are fine. Maybe I need to strip out the game logic and just get drawing working 1st...
  12. cornflake

    GDI issues again!

    Very quickly, thanks for all your help so far. I nearly have my first game written - 'Rectangular monsters from the 600x600 black square planet!!' Hmm... Anyway, I'm trying to draw things in Game_Init etc but it doesn;t work. Drawing only seems to work in the WinMain event loop. Here is my complete code - // My first game - based on T3D console app // INCLUDES /////////////////////////////////////////////// #define WIN32_LEAN_AND_MEAN // No FC #include <windows.h> // include important windows stuff #include <windowsx.h> #include <mmsystem.h> #include <iostream.h> // include important C/C++ stuff #include <conio.h> #include <stdlib.h> #include <malloc.h> #include <memory.h> #include <string.h> #include <stdarg.h> #include <stdio.h> #include <math.h> #include <io.h> #include <fcntl.h> // DEFINES //////////////////////////////////////////////// // defines for windows #define WINDOW_CLASS_NAME "WINCLASS1" // MACROS ///////////////////////////////////////////////// #define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0) #define KEYUP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1) // GLOBALS //////////////////////////////////////////////// HWND main_window_handle = NULL; // globally track main window HINSTANCE hinstance_app = NULL; // globally track hinstance int winheight = 600; // Initial Window Height int winwidth = 600; // Initial Window Width int score = 0; // Score int level = 1; // Level int leftlimit = 1; // Left movement limit int rightlimit = 550; // Right movement limit int toplimit = 30; // Top movement limit int botlimit = 550; // Bottom Movement limit char buffer[80]; // general printing buffer // Player vars int plife = 50; // Life int pxul = 40; // X Upper left int pyul = 40; // Y Upper left etc... int pxbr = 50; int pybr = 50; int pprevxul = 0; // Previous positions int pprevyul = 0; int pprevxbr = 0; int pprevybr = 0; // Enemy vars int exul = 300; // X Upper left int eyul = 300; // Y Upper left etc... int exbr = 310; int eybr = 310; int eprevxul = 0; // Previous positions int eprevyul = 0; int eprevxbr = 0; int eprevybr = 0; // Bullet vars int pbulletx = NULL; // Previous Position int pbullety = NULL; int bulletx = NULL; // Bullet x co-ord int bullety = NULL; // Bullet y co-ord int bulletaimx = NULL; // Bullet aim point x co-ord int bulletaimy = NULL; // Bullet aim point y co-ord int bulletspeed = 5; // Speed int brange = 100; // Range int bdistance = 0; // Distance Travelled // Global // FUNCTIONS ////////////////////////////////////////////// LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { // this is the main message handler of the system PAINTSTRUCT ps; // used in WM_PAINT HDC hdc; // handle to a device context char buffer[80]; // used to print strings // what is the message switch(msg) { case WM_CREATE: { // do initialization stuff here // return success return(0); } break; case WM_PAINT: { // simply validate the window hdc = BeginPaint(hwnd,&ps); // end painting EndPaint(hwnd,&ps); // return success return(0); } break; case WM_DESTROY: { // kill the application, this sends a WM_QUIT message PostQuitMessage(0); // return success return(0); } break; default:break; } // end switch // process any messages that we didn't take care of return (DefWindowProc(hwnd, msg, wparam, lparam)); } // end WinProc ////////////////////////////////////////////////////////////// int Game_Main(void *parms = NULL, int num_parms = 0) { // this is the main loop of the game, do all your processing // here // for now test if user is hitting ESC and send WM_CLOSE if (KEYDOWN(VK_ESCAPE)) SendMessage(main_window_handle,WM_CLOSE,0,0); // Player movement if arrow key pressed HDC hdc; HWND hwnd; hdc = GetDC(hwnd); if (KEYDOWN(VK_DOWN)) { // Get previous position pprevxul = pxul; pprevyul = pyul; pprevxbr = pxbr; pprevybr = pybr; // Increment position down pyul = pyul + 5; pybr = pybr + 5; } //end if if (KEYDOWN(VK_UP)) { // Get previous position pprevxul = pxul; pprevyul = pyul; pprevxbr = pxbr; pprevybr = pybr; // Increment position up pyul = pyul - 5; pybr = pybr - 5; } //end if if (KEYDOWN(VK_LEFT)) { // Get previous position pprevxul = pxul; pprevyul = pyul; pprevxbr = pxbr; pprevybr = pybr; // Increment position left pxul = pxul - 5; pxbr = pxbr - 5; } //end if if (KEYDOWN(VK_RIGHT)) { // Get previous position pprevxul = pxul; pprevyul = pyul; pprevxbr = pxbr; pprevybr = pybr; // Increment position right pxul = pxul + 5; pxbr = pxbr + 5; } //end if //Check movement limit // Top of screen if (pyul < toplimit) { pyul = toplimit; pybr = pyul + 10; } // Left of screen if (pxul < leftlimit) { pxul = leftlimit; pxbr = pxul + 10; } // Right of screen if (pxbr > rightlimit) { pxbr = rightlimit; pxul = pxbr - 10; } // Bottom of screen if (pybr > botlimit) { pybr = botlimit; pyul = pybr - 10; } // End player movement // TODO - Enemy AI // Enemy fires bullet at player if no bullet already if (bulletx == NULL) { // Check player is in range // initialise temp vars int pdistx = 0; int pdisty = 0; // get x distance if (pxul > exul) { pdistx = (pxul - exul); } else { pdistx = (exul - pxul); } // get y distance if (pyul > eyul) { pdisty = (pyul - eyul); } else { pdisty = (eyul - pyul); } // Fire if in range if ((pdistx < brange) && (pdisty < brange)) { bulletx = exul; // Bullet starts at Enemy position bullety = eyul; bulletaimx = pxul; // Bullet aimed at current player position bulletaimy = pyul; bdistance = 0; // Reset distance travelled } } // TODO - Enemy movement // End enemy movement // Bullet Processing if (bulletx != NULL) // If there is a bullet { // Save previous position pbulletx = bulletx; pbullety = bullety; // Check for collision if ((bulletx >= pxul) && (bulletx <= pxbr)) { if ((bullety >= pyul) && (bullety <= pybr)) { //Bullet collision with player plife = plife - 10; } } // Check for reach aimpoint if (bulletx == bulletaimx) { if (bullety == bulletaimy) { //RESET bulletx = NULL; bullety = NULL; bulletaimx = NULL; bulletaimy = NULL; } } // Move bullet closer to aim point if (bulletx > bulletaimx) { bulletx = bulletx - bulletspeed; } if (bulletx < bulletaimx) { bulletx = bulletx + bulletspeed; } if (bullety > bulletaimy) { bullety = bullety - bulletspeed; } if (bullety < bulletaimy) { bullety = bullety + bulletspeed; } //Increment Distance Travelled bdistance = bdistance + bulletspeed; //Check for range if (bdistance >= brange) { bulletx = NULL; // Kill bullet bullety = NULL; } } // Control speed Sleep(100); // return success return(1); } // end Game_Main //////////////////////////////////////////////////////////// int Game_Init(void *parms = NULL, int num_parms = 0) { // NOT WORKING ****************************** HWND hwnd; HDC hdc; hdc = GetDC(hwnd); HPEN black_pen = CreatePen(PS_SOLID, 1, RGB(0,0,0)); HBRUSH blue_brush = CreateSolidBrush(RGB(0,0,255)); // select pen and brush into context SelectObject(hdc, black_pen); SelectObject(hdc, blue_brush); // Erase previous player position Rectangle(hdc, 100,100,120,150); DeleteObject(blue_brush); DeleteObject(black_pen); ReleaseDC(hwnd, hdc); // return success or failure or your own return code here return(1); } // end Game_Init ///////////////////////////////////////////////////////////// int Game_Shutdown(void *parms = NULL, int num_parms = 0) { // this is called after the game is exited and the main event // loop while is exited, do all you cleanup and shutdown here // return success or failure or your own return code here return(1); } // end Game_Shutdown // WINMAIN //////////////////////////////////////////////// int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { WNDCLASSEX winclass; // this will hold the class we create HWND hwnd; // generic window handle MSG msg; // generic message HDC hdc; // graphics device context // first fill in the window class stucture winclass.cbSize = sizeof(WNDCLASSEX); winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hinstance; winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winclass.lpszMenuName = NULL; winclass.lpszClassName = WINDOW_CLASS_NAME; winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); // save hinstance in global hinstance_app = hinstance; // register the window class if (!RegisterClassEx(&winclass)) return(0); // create the window if (!(hwnd = CreateWindowEx(NULL, // extended style WINDOW_CLASS_NAME, // class "T3D Game 1.0", // title WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0,0, // initial x,y winwidth,winheight, // initial width, height NULL, // handle to parent NULL, // handle to menu hinstance,// instance of this application NULL))) // extra creation parms return(0); // save main window handle main_window_handle = hwnd; // get the dc and hold it //HDC hdc = GetDC(hwnd); NOT REQUIRED??? // initialize game here Game_Init(); // enter main event loop while(TRUE) { // test if there is a message in queue, if so get it if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { // test if this is a quit if (msg.message == WM_QUIT) break; // translate any accelerator keys TranslateMessage(&msg); // send the message to the window proc DispatchMessage(&msg); } // end if // main game processing goes here Game_Main(); // Draw Player //get DC hdc = GetDC(hwnd); // create pens and brushes HPEN blue_pen = CreatePen(PS_SOLID, 1, RGB(0,0,255)); HPEN black_pen = CreatePen(PS_SOLID, 1, RGB(0,0,0)); HBRUSH red_brush = CreateSolidBrush(RGB(200,0,100)); HBRUSH green_brush = CreateSolidBrush(RGB(0,255,0)); HBRUSH black_brush = CreateSolidBrush(RGB(0,0,0)); // select pen and brush into context SelectObject(hdc, black_pen); SelectObject(hdc, black_brush); //Wipe Screen Rectangle(hdc,0,0,winwidth,winheight); // Erase previous player position //Rectangle(hdc, pprevxul, pprevyul, pprevxbr, pprevybr); // Erase previous enemy position //Rectangle(hdc, eprevxul, eprevyul, eprevxbr, eprevybr); // Erase previous bullet position if relevant //if (pbulletx != NULL) //{ // Rectangle(hdc, pbulletx,pbullety, (pbulletx + 5),(pbullety + 5)); //} // Select new pen and brush SelectObject(hdc, blue_pen); SelectObject(hdc, green_brush); // draw new player Rectangle(hdc, pxul,pyul, pxbr,pybr); // Change brush DeleteObject(green_brush); SelectObject(hdc, red_brush); // Draw new enemy Rectangle(hdc, exul,eyul, exbr,eybr); //Draw bullet if (bulletx != NULL) { Rectangle(hdc, bulletx, bullety, (bulletx + 5),(bullety + 5)); } // delete the objects DeleteObject(red_brush); DeleteObject(blue_pen); DeleteObject(black_brush); DeleteObject(black_pen); // Show score SetBkColor(hdc, RGB(0,0,0)); SetTextColor(hdc, RGB(0,255,0)); //SetBkMode(hdc, TRANSPARENT); // Clear text area sprintf(buffer," "); TextOut(hdc,1,1,buffer,strlen(buffer)); TextOut(hdc,1,20,buffer,strlen(buffer)); // Show info sprintf(buffer,"Score %d Level %d Life %d",score,level, plife); TextOut(hdc,1,1,buffer,strlen(buffer)); sprintf(buffer,"bulletx %d bullety %d pxul %d pyul%d",bulletx,bullety,pxul,pyul); TextOut(hdc,1,20,buffer,strlen(buffer)); // release the device context ReleaseDC(hwnd,hdc); Sleep(10); } // end while // closedown game here Game_Shutdown(); ReleaseDC(hwnd, hdc); // return to Windows like this return(msg.wParam); } // end WinMain The drawing in Game_Init doesn't work for some reason, although it complies, and everything else works ok :( :(
  13. cornflake

    Bullet Firing

    Thanks for the example. One more idiot question - I understand the code except for the use of the * characters...
  14. cornflake

    Bullet Firing

    Quote:Original post by LMRFUD If you want a diagnal between 2 points then you might want to look a a tutorial like this http://www.falloutsoftware.com/tutorials/dd/dd4.htm Its a simple explanation, hope it helps. Fud That helped. Thanks. although I now know I need to look into vectors etc in a bit more detail :)
  15. cornflake

    Bullet Firing

    Quote:Original post by mikeman Normalize(A-M)*Constant; Getting lost here...
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!