HGE Homepage Relish Games
Innovative indie games and indie game development
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help beginner programmer

 
Post new topic   Reply to topic    Relish Games Forum Index -> Game Development
View previous topic :: View next topic  
Author Message
Darkkermi



Joined: 23 Feb 2010
Posts: 14
Location: Melbourne, FL

PostPosted: Tue Feb 23, 2010 4:54 am    Post subject: Help beginner programmer Reply with quote

Unhandled exception at 0x00a77c00 in TEST.exe: 0xC0000005 Access violation reading location 0x0000009c.

Code:
Code:
#include <windows>
#include <hge>
#include <hgeresource>
#include <hgesprite>
#include <hgeanim>

HGE *hge = 0;
hgeResourceManager* myRes;
hgeSprite* bgSprite;
hgeSprite* playerSprite;
hgeAnimation* star;

bool FrameFunc()
{
 float dt=hge->Timer_GetDelta();  //get the time since the last call to FrameFunc
 star->Update(dt);  //update the animation
 
 hge->Gfx_BeginScene();
 hge->Gfx_Clear(0);  //clear the screen, filling it with black
 bgSprite->RenderStretch(0, 0, 800, 600); //render the background sprite stretched
 playerSprite->Render(200, 200); //render the player sprite
 star->Render(400, 300); //render the animation of a star
 
 hge->Gfx_EndScene();

 return false;
}

int WINAPI WinMain (HINSTANCE,HINSTANCE,LPSTR,int)

{
  hge = hgeCreate(HGE_VERSION);
  hge->System_SetState(HGE_WINDOWED, true);
  hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
  hge->System_SetState(HGE_TITLE, "HGE Tutorial");
 
  if(hge->System_Initiate())
  {
    myRes = new hgeResourceManager("resource.res");
    bgSprite = myRes->GetSprite("bgSprite");
    playerSprite = myRes->GetSprite("playerSprite");
    star = myRes->GetAnimation("star");  //start playback of animation
    star->Play();
   
    hge->System_Start();
  }
  else
  {   
    MessageBox(NULL, hge->System_GetErrorMessage(), "Error",MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
  }
 
  delete myRes;
 
  hge->System_Shutdown();
  hge->Release();

  return 0;
}

I got this straight from the tutorial. It seems to be a dynamic error.


Last edited by Darkkermi on Tue Feb 23, 2010 9:37 pm; edited 1 time in total
Back to top
View user's profile Send private message
ProfEclipse
Expert


Joined: 10 Mar 2005
Posts: 1516
Location: Orlando, FL USA

PostPosted: Tue Feb 23, 2010 6:58 am    Post subject: Reply with quote

Add:
Code:

hge->System_SetState(HGE_LOGFILE,"test.log");


Then run your program and check the log file. It looks like you've got a NULL pointer somewhere which, in your case, probably indicates an error loading a resource.
Back to top
View user's profile Send private message
Darkkermi



Joined: 23 Feb 2010
Posts: 14
Location: Melbourne, FL

PostPosted: Tue Feb 23, 2010 5:47 pm    Post subject: Reply with quote

I think i found it! it says:

Code:
HGE Started..

HGE version: 1.80
Date: 23.02.2010, 16:38:32

Application: HGE Tutorial
OS: Windows 6.0.6002
Memory: 2097151K total, 1685724K free

D3D Driver: igdumd32.dll
Description: Mobile Intel(R) 965 Express Chipset Family
Version: 7.14.10.1409
Mode: 800 x 600 x X8R8G8B8

Sound Device: Speakers / Headphones (SigmaTel High Definition Audio CODEC)
Sample rate: 44100

Init done.

Can't load resource: resource
Script 'resource' not found.


Last edited by Darkkermi on Tue Feb 23, 2010 9:46 pm; edited 1 time in total
Back to top
View user's profile Send private message
DaiShiva
Expert


Joined: 03 Mar 2004
Posts: 702
Location: Tucson, AZ

PostPosted: Tue Feb 23, 2010 9:45 pm    Post subject: Reply with quote

Do the precompiled tutorials run?

Are you able to compile any of the tutorials?
Back to top
View user's profile Send private message Visit poster's website
Darkkermi



Joined: 23 Feb 2010
Posts: 14
Location: Melbourne, FL

PostPosted: Tue Feb 23, 2010 9:47 pm    Post subject: Reply with quote

yea the precompiled all run and i was able to run the first tutorial fine but i cant get the others to run
Back to top
View user's profile Send private message
ProfEclipse
Expert


Joined: 10 Mar 2005
Posts: 1516
Location: Orlando, FL USA

PostPosted: Tue Feb 23, 2010 10:17 pm    Post subject: Reply with quote

I'll bet when you saved your resource.res file, it actually saved as resource.res.txt. Bring up your Windows Explorer/Folder Options/View options and uncheck "Hide extensions for known file types".
Back to top
View user's profile Send private message
Darkkermi



Joined: 23 Feb 2010
Posts: 14
Location: Melbourne, FL

PostPosted: Tue Feb 23, 2010 11:50 pm    Post subject: Reply with quote

http://my.fit.edu/~kstrachan2008/r.jpg
Back to top
View user's profile Send private message
ProfEclipse
Expert


Joined: 10 Mar 2005
Posts: 1516
Location: Orlando, FL USA

PostPosted: Wed Feb 24, 2010 12:46 am    Post subject: Reply with quote

HGE searches for resources relative to the directory that contains the executable, not the project directory. You need to move your resources into the directory that contains TEST.exe.
Back to top
View user's profile Send private message
Darkkermi



Joined: 23 Feb 2010
Posts: 14
Location: Melbourne, FL

PostPosted: Wed Feb 24, 2010 1:25 am    Post subject: Reply with quote

that did the trick thanks alot! Very Happy
Back to top
View user's profile Send private message
ProfEclipse
Expert


Joined: 10 Mar 2005
Posts: 1516
Location: Orlando, FL USA

PostPosted: Wed Feb 24, 2010 4:57 am    Post subject: Reply with quote

You're welcome!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Relish Games Forum Index -> Game Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group