Thread: Using C++ to create a Vertical Shooter

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    13

    Using C++ to create a Vertical Shooter

    Kinda like space invaders idea.
    I broke the task into milestones and created functions to clear the screen to an arbitrary colour & to set the pixels on screen to an arbitrary colour (to give the effect of a starry background...like outer space)

    Currently i'm writing code to load a texture (eg:spaceship) and use clipping & blitting functions to show that texture move around screen and be shown partially off the edge of the screen.
    Have implemented a rectangle class and created a sourceRectangle (the texture) and destinationRectangle (the screen) to do this.

    Also i am writing code for a visualisation class which:
    - creates & stores collections of sprites
    and a sprite class which:
    -contains texture and can draw it@specific onscreen location
    -knows about animation frames
    -requires create & render functions

    A vector class will be needed also.


    If you read all that you will probably be quite confused, i need to get this altogether and coded with clarity so its a working 2D shooter game, i still have to stick in collision checking, AI, UI and worldentities if im to get a good grade (this is a project due in jan30th).

    My question is, can anybody give me some links to similar games which would be using this kind of code creation. if i could see source code for simliar C++ vertical shooters it would be a good help. and if anybody has written these type of games and pearls of wisdom are welcome.

    thanks in advance,

    mindofpoison

  2. #2
    C(++)(#)
    Join Date
    Jul 2004
    Posts
    309
    What API are you using?
    To code is divine

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    If this is DX or GDI I have animation classes for both.

    API of choice here would help us more.

  4. #4
    Registered User
    Join Date
    Nov 2005
    Posts
    13
    im using visual studio.net 2003.....
    programming in C++....
    DirectX 9.0 is installed...
    and the API?

    Is one called HAPI (Hardware Application Program Interface) - created by university tutor.

    Obviously nobody then will have used it (unless you go to the university of teesside) but it shouldnt matter too much as i'm just looking some help on programming a 2D vertical shooter spaceship type game in C++...using classes like vector, animation, sprite, visualisation and then sticking in some UI, AI and sound for the extra marks.
    Any relevant help appreciated!

  5. #5
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Well you just encapsulated about 8K lines in that paragraph. I have an engine that can do all of this, but I doubt that is what you want. What do you need help on. I'm fairly sure I can do all of that or at least know how to do it.

    For user interface you could use a pre-built library by MS that is a framework for a DX GUI and it acts similar to the Windows message-based system.

    But you could build your own too.

    If this is for a project for uni, I'd go with a simple UI that had the bitmaps either drawn into the image (like for a title screen) and then just add a button structure to an array and track the mouse by iterating the array when the mouse button was pressed.

    Code:
    if (mouse.buttondown==0x01)
    {
      bool bButtonFound=false;
      for (int i=0;i<ButtonSys.NumButtons;i++)
      {
         if (PtInRect(mouse.Pos,ButtonSys[i].rect))
         {
            bButtonFound=true;
            break;
         }
       }
    
       if (bButtonFound)
       {
          SendMessage(ButtonSys[i].m_pParent,UI_BTNPUSHED);
       } 
        else  ...
        ...
    }
    Something like that would do.

    For Vector operations you can just use D3DXVECTOR2 as it provides all the functionality you need.

    Code:
    void CObject::Target(CObject *pTarget)
    {
      D3DXVECTOR2 ToTarget=Pos-pTarget->Pos;
      D3DXVec2Normalize(&ToTarget,&ToTarget);
    
      SetFireVector(ToTarget);
    }
    Last edited by VirtualAce; 01-02-2006 at 10:45 AM.

  6. #6
    Registered User
    Join Date
    Nov 2004
    Location
    Pennsylvania
    Posts
    434
    Sounds cool, you'll have to post the source code and or program when your done. Sounds like fun!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can't create child windows
    By OnionKnight in forum Windows Programming
    Replies: 4
    Last Post: 04-10-2011, 04:13 PM
  2. Create new combo boxes based on items selected in preview combo box
    By RealityFusion in forum Windows Programming
    Replies: 2
    Last Post: 01-10-2007, 09:50 AM
  3. Create a file from c++ program
    By Dan17 in forum C++ Programming
    Replies: 2
    Last Post: 05-08-2006, 04:25 PM
  4. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  5. How to Create reference to an array in C++
    By shiv_tech_quest in forum C++ Programming
    Replies: 2
    Last Post: 12-20-2002, 10:01 AM