Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Trouble with background

Author
Message
Nextmastermind
15
Years of Service
User Offline
Joined: 23rd Jun 2009
Location:
Posted: 14th Jul 2009 02:00
Ok, so I want menuscroll.jpg to be my background. When i run this code I get an error, but if I hit ok, everything else ends up fine, but the menu doesn't show. Help? Here is the code:

Quote: "#include "DarkGDK.h"

bool InTitle = true;

bool MouseInRectangle ( float x1, float y1, float x2, float y2 );

void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
dbSetImageColorKey ( 255, 255, 255 );
sbLoadImage ( "MenuScroll.png", 1 );
dbLoadImage ( "_NewGame.png", 2 );
dbLoadImage ( "_LoadGame.png", 3 );
dbLoadImage ( "_Options.png", 4 );
dbLoadImage ( "_Exit.png", 5 );
dbSprite ( 1, dbScreenWidth ( ) / 2 - 50, 100, 1 );
dbSprite ( 2, dbScreenWidth ( ) / 2 - 50, 180, 2 );
dbSprite ( 3, dbScreenWidth ( ) / 2 - 50, 210, 3 );
dbSprite ( 4, dbScreenWidth ( ) / 2 - 50, 240, 4 );
dbSprite ( 5, dbScreenWidth ( ) / 2 - 50, 270, 5 );

while ( LoopGDK ( ) )
{
if ( InTitle == true )
{
if ( MouseInRectangle ( dbScreenWidth ( ) / 2 - 50, 280, dbScreenWidth ( ) / 2 + 50, 312 ) )
{
if ( dbMouseClick ( ) == 1 )//1 = Left Click, 2 = Right Click
{
InTitle = false;
//New Game Code
}
else
{
//Mouse Hovering Over Button Code (just to make it look nice)
}
}
else
if ( MouseInRectangle ( dbScreenWidth ( ) / 2 - 50, 320, dbScreenWidth ( ) / 2 + 50, 352 ) )
{
if ( dbMouseClick ( ) == 1 )//1 = Left Click, 2 = Right Click
{
InTitle = false;
//Load Game Code
}
else
{
//Mouse Hovering Over Button Code (just to make it look nice)
}
}
else
if ( MouseInRectangle ( dbScreenWidth ( ) / 2 - 50, 360, dbScreenWidth ( ) / 2 + 50, 392 ) )
{
if ( dbMouseClick ( ) == 1 )//1 = Left Click, 2 = Right Click
{
//Options Code
}
else
{
//Mouse Hovering Over Button Code (just to make it look nice)
}
}
else
if ( MouseInRectangle ( dbScreenWidth ( ) / 2 - 50, 400, dbScreenWidth ( ) / 2 + 50, 432 ) )
{
if ( dbMouseClick ( ) == 1 )//1 = Left Click, 2 = Right Click
{
exit ( 1 );
}
else
{
//Mouse Hovering Over Button Code (just to make it look nice)
}
}
}
dbSync ( );
}
return;
}

bool MouseInRectangle ( float x1, float y1, float x2, float y2 )
{
float MX = dbMouseX ( );
float MY = dbMouseY ( );
if ( MX > x1 && MY > y1 && MX < x2 && MY < y2 )
return true;
else
return false;
}"
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 14th Jul 2009 02:37
First, you need to make sure that the path you are loading them from is where they are.... atm acording to ur code, they need to be in the project's root folder.

Also, the image wont showup after loading until you paste it somewhere with dbPasteImage(). Although you will need to paste it each loop to ensure it stays there I think(might be wrong on that, been awhile since ive used background images in an app)

Another option is to make it a sprite and place it where you want it, although it may interfere with sprite collision if you do that.

Lastly you can make a 3d object, and texture your image onto it, then place the object where you want it(a large plain placed close to the camera can work, this is also a good way to create a user interface, as 3d objects can be affected by light and shaders, where images on their own cant be.

If it ain't broke.... DONT FIX IT !!!
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 14th Jul 2009 16:00


Im pretty sure this needs to be in your main loop.
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 14th Jul 2009 21:08
Quote: "When i run this code I get an error"


What error exactly? If there is an error message, it should at least hint at what the problem is.

Also, did you retype this whole code or copy-pasted? Because you wrote sbLoadImage instead of dbLoadImage, this shouldn't even compile.

Quote: "Ok, so I want menuscroll.jpg to be my background. "


Here you wrote jpg but in the code the extension is png. Which is the correct one? If only this image does not show up and the rest do, then the image is not found. Did you type the name and extension correctly?

Login to post a reply

Server time is: 2024-10-01 08:19:05
Your offset time is: 2024-10-01 08:19:05