Questions - It's time for the drilling of questions.........
  • TimidonTimidon June 2004
    I will admit, I am a amuture programer (with limited funds for programs and equipment). Now that I got my IDE & compiler working, I am going to start asking questions. I have used Allegro for sometime. I will admit, it's a nice library once you get the kinks out of it, I am thinking I am going try this out for a while and see how it works out for me.

    The tools I am using, are Dev-Cpp (latest version 4.9.x), the mingw32 compilier. Neopaint, Gimp.

    Textures is a odd name for me. Though from what I gather Textures is bitmap that can be placed onto the screen Just looking on how to do it.

    Mostly it the NOT understanding on how the textures are being added to the screen. I have been looking at the tutorials and begining to scratch my head (used to looking at the Allegro lib).

    So Let me see how loud the dog is barking (and which tree it is barking in). I also use these forums to ask questions that I may eventually answer myself as I go through you will see it from a newby point of veiw, so I hope it helps all who read through my rattlings.

    Thanks, Timidon.
  • TimidonTimidon June 2004
    This is basicly the first Tutorial
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    /*
    ** Haaf's Game Engine 1.4
    ** Copyright (C) 2003-2004, Relish Games
    ** hge.relishgames.com
    **
    ** hge_tut01 - Minimal HGE application
    */

     
    #include "..\..\include\hge.h"
    #include "..\..\include\hgesprite.h"
    #include "..\..\include\hgefont.h"
     
    HGE *hge = 0;
    // Handles for HGE resourcces
    HTEXTURE tex;
     
    // This function will be called by HGE once per frame.
    // Put your game loop code here. In this example we
    // just check whether ESC key has been pressed.
     
    // *************************************************************************
    // * Main Loop
    // *************************************************************************
    bool FrameFunc()
    {
    // By returning "true" we tell HGE
    // to stop running the application.
    if (hge->Input_GetKeyState(HGEK_ESCAPE)) return true;
     
    // Continue execution
    return false;
    }
    // *************************************************************************
    // * Games Main Function - First thing looked for , ,, ,
    // *************************************************************************
     
    int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
    {
    // Here we use global pointer to HGE interface.
    // Instead you may use hgeCreate() every
    // time you need access to HGE. Just be sure to
    // have a corresponding hge->Release()
    // for each call to hgeCreate()
    hge = hgeCreate(HGE_VERSION);
    // * New Stuff
    hge->System_SetState(HGE_LOGFILE, "AST.log");
    hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
    // Set the window title
    hge->System_SetState(HGE_TITLE, "Test");
    // Run in Window
    hge->System_SetState(HGE_WINDOWED, true);
    // Size
    hge->System_SetState(HGE_SCREENWIDTH, 800);
    hge->System_SetState(HGE_SCREENHEIGHT, 600);
    hge->System_SetState(HGE_SCREENBPP, 32);
    // Set our frame function
    hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
     
     
     
     
     
    // Don't use BASS for sound
    hge->System_SetState(HGE_USESOUND, false);
     
    // Tries to initiate HGE with the states set.
    // If something goes wrong, "false" is returned
    // and more specific description of what have
    // happened can be read with System_GetErrorMessage().
    if(hge->System_Initiate())
    {
    // Starts running FrameFunc().
    // Note that the execution "stops" here
    // until "true" is returned from FrameFunc().
    // bkg_1=hge->Texture_Load("bg.png");
    // Create Base
    tex=hge->Texture_Create(64,64);
    tex=hge->Texture_Load("test1.png");
    hge->System_Start();
    }
    else
    {
    // If HGE initialization failed show error message
    MessageBox(NULL, hge->System_GetErrorMessage(), "Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
    }
     
    // Now ESC has been pressed or the user
    // has closed the window by other means.
     
    // Restore video mode and free
    // all allocated resources
    hge->System_Shutdown();
     
    // Release the HGE interface.
    // If there are no more references,
    // the HGE object will be deleted.
    hge->Release();
     
    return 0;
    }

    Continued...[/code]
  • TimidonTimidon June 2004
    I understand that the tutorials calls this function up, this is where you do the action at
    1
    2
    3
    4
    5
    6
    7
    8
    9
    bool FrameFunc() 
    {
    // By returning "true" we tell HGE
    // to stop running the application.
    if (hge->Input_GetKeyState(HGEK_ESCAPE)) return true;
     
    // Continue execution
    return false;
    }


    This is nice, gives the function a out if something goes bad.

    Now more stating of the obvious,... These happen within this function

    // This function must be called
    // before any actual rendering.
    hge->Gfx_BeginScene();

    * "hge->Gfx-BeginScene();" I see is called before the objects are put to screen.

    * Place More information here... then

    * "hge->Gfx_EndScene();" is used to to stop putting objects to the screen and does the page flipping.

    Contiuned..
  • TimidonTimidon June 2004
    This is where I am getting a little confused,

    I am trying to place just a static object to the screen. I beleive this is called a Texture. Sprites would pass over it.

    tex is the name of the Texture I plan on using,
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    if(hge->System_Initiate())
    if(hge->System_Initiate())
    {
    // Starts running FrameFunc().
    // Note that the execution "stops" here
    // until "true" is returned from FrameFunc().
    // bkg_1=hge->Texture_Load("bg.png");
    // Create Base
    tex=hge->Texture_Create(64,64);
    tex=hge->Texture_Load("test1.png");
    hge->System_Start();
    }


    create a empty texture, then load a png file onto it.

    The next step I am confused on is how to place that object on to the screen between BeginScene & EndScene. I dont see a clear example. Sudgestions..
  • TimidonTimidon June 2004
    ps

    I was thumbing through the forum, and found this tad bit.


    Hello,
    A newbie question. I have a 800x600 bmp that is my background.What class should I use to render it to the screen and get the best fps?
    Thanks for you help.
    Julio




    "texCoroa=hge->Texture_Load("background.bmp");
    coroaVerm = new hgeSprite(texCoroa,0,0,800,600);
    coroaVerm->SetHotSpot(0,0); "



    So If I read this correctly, a Texture is basicl a sprite also. You would need to load the picture onto the Object and then display it like a sprite? (come to think of it now, Allegro Bitmap* where handeled similairly.
  • depsdeps June 2004
    You use hge->Texture_Load to upload the image to your videocard ram, and you then use the returned value to create a sprite, for example.

    If i will try to speak allegro

    hgeSprite is more like an BITMAP* than what HTEXTURE is.

    so this in allegro:

    BITMAP* image = load_bmp("myimg.bmp", NULL);

    could look like this in hge:

    HTEXTURE mytex = hge->Texture_Load("myimg.bmp");
    hgeSprite image = nre hgeSprite( mytex, 0,0, 64, 64 );

    And drawing:

    allegro: draw_sprite( screen, image, x,y );

    hge: image->Render( x, y );



    hope that helps. :)
  • TimidonTimidon June 2004
    Alright, after looking at the code and placing a Single Object down, I am rather happy, it was rather painless.

    So this is what the final code looks like..
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    /*
    ** Haaf's Game Engine 1.4
    ** Copyright (C) 2003-2004, Relish Games
    ** hge.relishgames.com
    **
    ** hge_tut01 - Minimal HGE application
    */

     
    #include "..\..\include\hge.h"
    #include "..\..\include\hgesprite.h"
    #include "..\..\include\hgefont.h"
     
    HGE *hge = 0;
    // Handles for HGE resourcces
    HTEXTURE tex;
    hgeSprite* Iso1;
     
    // This function will be called by HGE once per frame.
    // Put your game loop code here. In this example we
    // just check whether ESC key has been pressed.
     
    // *************************************************************************
    // * Main Loop
    // *************************************************************************
    bool FrameFunc()
    {
    // By returning "true" we tell HGE
    // to stop running the application.
    if (hge->Input_GetKeyState(HGEK_ESCAPE)) return true;
    // **************************************************
    // * Do the Behind the Scense Stuff, such as needed up to date calclations
     
     
     
     
    // ********************
    // * Render Scence
    // ********************
     
    hge->Gfx_BeginScene();
    Iso1->Render(250,250);
    hge->Gfx_EndScene();
     
    // *********************
    // * End Scence
    // *********************
     
    // Continue execution
    return false;
    }
    // *************************************************************************
    // * Games Main Function - First thing looked for , ,, ,
    // *************************************************************************
     
    int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
    {
    // Here we use global pointer to HGE interface.
    // Instead you may use hgeCreate() every
    // time you need access to HGE. Just be sure to
    // have a corresponding hge->Release()
    // for each call to hgeCreate()
    hge = hgeCreate(HGE_VERSION);
    // * New Stuff
    hge->System_SetState(HGE_LOGFILE, "AST.log");
    hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
    // Set the window title
    hge->System_SetState(HGE_TITLE, "Test");
    // Run in Window
    hge->System_SetState(HGE_WINDOWED, true);
    // Size
    hge->System_SetState(HGE_SCREENWIDTH, 800);
    hge->System_SetState(HGE_SCREENHEIGHT, 600);
    hge->System_SetState(HGE_SCREENBPP, 32);
    // Set our frame function
    hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
     
     
     
     
     
    // Don't use BASS for sound
    hge->System_SetState(HGE_USESOUND, false);
     
    // Tries to initiate HGE with the states set.
    // If something goes wrong, "false" is returned
    // and more specific description of what have
    // happened can be read with System_GetErrorMessage().
    if(hge->System_Initiate())
    {
    // Starts running FrameFunc().
    // Note that the execution "stops" here
    // until "true" is returned from FrameFunc().
    // bkg_1=hge->Texture_Load("bg.png");
    // Create Base
    // tex=hge->Texture_Create(64,64);
    tex=hge->Texture_Load("test1.png");
    Iso1 = new hgeSprite(tex,0,0,64,64);
    Iso1->SetHotSpot(100.0,100.0);
    hge->System_Start();
    }
    else
    {
    // If HGE initialization failed show error message
    MessageBox(NULL, hge->System_GetErrorMessage(), "Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
    }
     
    // Now ESC has been pressed or the user
    // has closed the window by other means.
     
    // Restore video mode and free
    // all allocated resources
    hge->System_Shutdown();
     
    // Release the HGE interface.
    // If there are no more references,
    // the HGE object will be deleted.
    hge->Release();
     
    return 0;
    }


    The changes that I did do where these..

    Before the functions I added this varible
    1
    hgeSprite*			Iso1;



    Then added this to the int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) function
    1
    2
    3
    tex=hge->Texture_Load("test1.png");		
    Iso1 = new hgeSprite(tex,0,0,64,64);
    Iso1->SetHotSpot(100.0,100.0);


    What was done here, was create a Texture with the bitmap then placed that Texture on a Sprite named Iso1.

    and added this to the FramFunc Function
    1
    	Iso1->Render(200.0,200.0);


    The Render Function is pretty much what I was looking for, this was the big one to Place to screen. This placed Iso1 on the screen.

    Well it's 2am and it's time for some sleep, Good night all. Thanks for reading.
  • TimidonTimidon June 2004
    As I was working through it, I came to same conclusion. Deps you speak Allegro well. I have a tendacy of trying to talk my way through something and ask the questions and answer them as I go. Thanks.
  • DaiShivaDaiShiva June 2004
    That looks a lot like how i started using hge, start small, work your way up =)
  • TimidonTimidon June 2004
    I do agree, get one thing working, then move onto the next. Just got stuck again, my compiler has gone haywire when I tried to add fonts.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

In this Discussion

Who's Online (0)