• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Alpha_ProgDes

Buffered Input....

0 posts in this topic

here's my stab at it:
//////////////////////////////////////////////////////////////////////////////
//   _____                      __  __       _                              //
//  / ____|                    |  \/  |     (_)                             //
// | |  __  __ _ _ __ ___   ___| \  / | __ _ _ _ __       ___ _ __  _ __    //
// | | |_ |/ _` | '_ ` _ \ / _ \ |\/| |/ _` | | '_ \     / __| '_ \| '_ \   //
// | |__| | (_| | | | | | |  __/ |  | | (_| | | | | | _ | (__| |_) | |_) |  //
//  \_____|\__,_|_| |_| |_|\___|_|  |_|\__,_|_|_| |_|(_) \___| .__/| .__/   //
//                                                           | |   | |      //
//                                                           |_|   |_|      //
//////////////////////////////////////////////////////////////////////////////


/*This is used in Tutorial 4.00 - 4.05 */

 

#define GLOBALS_OWNERSHIP
#include "Globals.h"
#include <string.h>

//----------------------------------------------------------------------------
// Local Function Declarations
//----------------------------------------------------------------------------
void EraseBackground();
void Game_Main();
void DrawFont(int x, int y, const char *pszText);
//------------------------------------------------------------------------
// Local Definitions


//------------------------------------------------------------------------
// This is a shortcut for checking the state of a key using DirectInput
#define KEYDOWN(key) (G.KeyState[key] & 0x80)
// This converts an R,G,B set to a 16-bit color (565)
#define RGB16COLOR(r,g,b) ((r << 11) + (g << 5) + b)

#define KEYDOWN2(i) (G.ddod[i].dwData & 0x80)
//////////////////////////////////////////////////////////////////////////////
// Game_Main
//
// This function is called once per frame.
//
void Game_Main()
{
    HRESULT hRet;
    static int j = 0;
    static char typing3[256];
    static char typing[256];
    static char typing2[16][16];
    static int letterCounter = -1; 
    DWORD arrayNum = 10;
    
    
    while (hRet = G.lpDIKeyboard->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), G.ddod, &arrayNum, 0)
           == DIERR_INPUTLOST)
    {
        // Acquire the keyboard
        if (FAILED(hRet = G.lpDIKeyboard->Acquire())) break;
    }
 
    char letter = ' ';
    for (DWORD i = 0; i < arrayNum; ++i) {
        
        if (G.ddod[i].dwData & 0x80) {
            switch (G.ddod[i].dwOfs) {
           
            case DIK_A: letter = 'A';
                         break;
            case DIK_B: letter = 'B';
                         break;
            case DIK_C: letter = 'C';
                         break;
            case DIK_D: letter = 'D';
                         break;
            case DIK_E: letter = 'E';
                         break;
            case DIK_F: letter = 'F';
                         break;
            case DIK_G: letter = 'G';
                         break;
            case DIK_H: letter = 'H';
                         break;
            case DIK_I: letter = 'I';
                         break;
            case DIK_J: letter = 'J';
                         break;
            case DIK_K: letter = 'K';
                         break;
            case DIK_L: letter = 'L';
                         break;
            case DIK_M: letter = 'M';
                         break;
            case DIK_N: letter = 'N';
                         break;
            case DIK_O: letter = 'O';
                         break;
            case DIK_P: letter = 'P';
                         break;
            case DIK_Q: letter = 'Q';
                         break;
            case DIK_R: letter = 'R';
                         break;
            case DIK_S: letter = 'S';
                         break;
            case DIK_T: letter = 'T';
                         break;
            case DIK_U: letter = 'U';
                         break;
            case DIK_V: letter = 'V';
                         break;
            case DIK_W: letter = 'W';
                         break;
            case DIK_X: letter = 'X';
                         break;
            case DIK_Y: letter = 'Y';
                         break;
            case DIK_Z: letter = 'Z';
                         break;

            default: break;
            }
        }
    }
    
    if (letter != ' ')
        typing[j] = letter; 
        
    strcpy(typing3, typing); 
      
    DrawFont(j*13, 240, &typing[j]);
    DrawFont(0, 260, typing3);
    
    G.lpDDSPrimary->Flip(NULL, 0);
    if (strlen(typing)-1 == j)
        ++j;
    
    if (j > 53)
        j = 0;
    
}

 
/***************************************************************************/
//////////////////////////////////////////////////////////////////////////////
// EraseBackground
//
// This will clear the entire display surface (i.e. the backbuffer) to the
// color BLACK.
//
void EraseBackground()
{
    HRESULT hRet;
    DDBLTFX ddbltfx;

    // Prepare for a black color blt
    ddbltfx.dwSize      = sizeof(DDBLTFX);
    ddbltfx.dwFillColor = 0;

    while (TRUE)
    {
        // Blt the color BLACK over the entire backbuffer
        hRet = G.lpDDSBack->Blt(NULL, NULL, NULL, 
                                DDBLT_COLORFILL|DDBLT_WAIT, &ddbltfx);
        if (SUCCEEDED(hRet)) break;

        // If the surfaces are lost, restore them and try again
        if (hRet == DDERR_SURFACELOST)
            if (FAILED(hRet = RestoreAll())) break;
        else break;
    }
}

void DrawFont(int x, int y, const char *pszText)
{
    // Font definitions
    #define ALPHA_LARGE_STARTX  0
    #define ALPHA_LARGE_STARTY  0
    #define ALPHA_LARGE_WIDTH   11
    #define ALPHA_LARGE_HEIGHT  13
 
    #define ALPHA_SMALL_STARTX  0
    #define ALPHA_SMALL_STARTY  13
    #define ALPHA_SMALL_WIDTH   11
    #define ALPHA_SMALL_HEIGHT  17
 
    #define NUMERIC_STARTX      0
    #define NUMERIC_STARTY      29
    #define NUMERIC_WIDTH       11
    #define NUMERIC_HEIGHT      13
   
    enum charWidth {ALW, ASW, NW} CharWidth;
    
    RECT rectSrc, rectDst;
    int location = 0;
    int letterSpacing;
    char curr;
    
    DDBLTFX ddbltfx;
    DDSURFACEDESC ddsd;
    
    INIT_STRUCT(ddsd);
    INIT_STRUCT(ddbltfx);

    // Go through each character in the given string

    for (int i = 0; i < (int)strlen(pszText); i++)
    {
        // Get the current character

        curr = pszText[i];
        
        // Capital letter?

        if (curr >= 'A' && curr <= 'Z')
        {
            rectSrc.left = ALPHA_LARGE_STARTX + ((curr - 'A') * ALPHA_LARGE_WIDTH);
            rectSrc.top = ALPHA_LARGE_STARTY;
            rectSrc.right = rectSrc.left + ALPHA_LARGE_WIDTH - 1;
            rectSrc.bottom = rectSrc.top + ALPHA_LARGE_HEIGHT - 1;
 
            letterSpacing = ALPHA_LARGE_WIDTH;
            CharWidth = ALW;
        }
        
        // Small letter?

        else if (curr >= 'a' && curr <= 'z')
        {
            rectSrc.left = ALPHA_SMALL_STARTX + ((curr - 'a') * ALPHA_SMALL_WIDTH);
            rectSrc.top = ALPHA_SMALL_STARTY;
            rectSrc.right = rectSrc.left + ALPHA_SMALL_WIDTH - 1;
            rectSrc.bottom = rectSrc.top + ALPHA_SMALL_HEIGHT - 1;
 
            letterSpacing = ALPHA_SMALL_WIDTH;
            CharWidth = ASW;
        }
 
        // Number?

        else if (curr >= '0' && curr <= '9')
        {
            rectSrc.left = NUMERIC_STARTX + ((curr - '0') * NUMERIC_WIDTH);
            rectSrc.top = NUMERIC_STARTY;
            rectSrc.right = rectSrc.left + NUMERIC_WIDTH - 1;
            rectSrc.bottom = rectSrc.top + NUMERIC_HEIGHT - 1;
 
            letterSpacing = NUMERIC_WIDTH;
            CharWidth = NW;
        }
        
        // Other (space or non-supported character)

        else
        {
            // If it's a space, move over one character (screen position)

            if (curr == ' ') location++;
            
            // Skip to the next character in the string

            continue;
        }
 
        // Draw this character to the backbuffer at the proper location
        rectDst.top = y;
        rectDst.left = x + (location++ * letterSpacing);
        rectDst.right = rectDst.left + 11;
        rectDst.bottom = rectDst.top + 15;
       
        switch (CharWidth) {
            
            case ALW: rectDst.bottom = rectDst.top + ALPHA_LARGE_HEIGHT - 1; break;
            case ASW: rectDst.bottom = rectDst.top + ALPHA_SMALL_HEIGHT - 1; break;
            case NW:  rectDst.bottom = rectDst.top + NUMERIC_HEIGHT - 1; break;
            default: break;
        }
      
        G.lpDDSBack->Blt(&rectDst, G.lpDDSRes, &rectSrc, DDBLT_WAIT, NULL); 
        
        
    }
}
// ---------------------------------------------------------------------------
// GameMain.cpp - End of file
// ---------------------------------------------------------------------------

i haven't gotten all the kinks out but it's definitely doing what i want it to do. so for now, i'm quite satisfied [grin]
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0