Why wont this work?

Posted By: gamingfan101

Why wont this work? - 06/10/09 01:27

hi, im trying to put a button on my background image, but nothing is there. heres the code im using and advice would be greatly appreciated!


////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
////////////////////////////////////////////////////////////////////

BMAP* firebackground = "awesome-fire-dragon-ablaze.jpg"; // dragon fire background with button on it

PANEL* first_pan = // my first panel
{
pos_x = -40;
pos_y = 0;
layer = 1;
bmap = firebackground;
button(-270, -100, "stopclicked.jpg", "stopnormal.jpg", "stopnormal.jpg", quit_program, NULL, NULL);
flags = OVERLAY | VISIBLE;
}
BMAP* pngRobot = "LDDScreenShot1.png"; // robot in foreground

PANEL* second_panel =
{
pos_x = -270;
pos_y = -100;
layer = 2;
bmap = pngRobot;
flags = OVERLAY | VISIBLE;
}

/////////////////////////////////////////////////////////////////////

function main ()
{
video_mode = 7;
screen_color.red = 100;
}

function quit_program()
{
while (key_any) {wait (1);}
sys_exit(NULL);
}
Posted By: Widi

Re: Why wont this work? - 06/10/09 09:37

Why you use -270? So the Button is outside from the Panel !!!
Posted By: croman

Re: Why wont this work? - 06/10/09 09:42

yea, don't use negative values for panel elements
the element wont be visible if it's not inside the panel
Posted By: gamingfan101

Re: Why wont this work? - 06/10/09 18:00

im not sure what happaned, everything but the button shows up where i want it.
Posted By: gamingfan101

Re: Why wont this work? - 06/10/09 18:01

ok, i changed the negative numbers, and it shows up now, but it doesnt doing anything when i click on it.
Posted By: alibaba

Re: Why wont this work? - 06/10/09 18:13

remove this you dont need it:
while (key_any) {wait (1);}
Posted By: gamingfan101

Re: Why wont this work? - 06/10/09 18:30

ok, but the button still doesnt work, i click on it and it does nothing
Posted By: Joozey

Re: Why wont this work? - 06/10/09 18:43

Add a wait(1) after the sys_exit()
Posted By: gamingfan101

Re: Why wont this work? - 06/10/09 18:46

ok, i did, but the button still wont work.
Posted By: Joozey

Re: Why wont this work? - 06/10/09 18:52

Oh, sorry, I realise you don't have a mouse yet. Create a mouse first so clicks and touches can be registrated by the engine.

Code:
function mouse() {
	mouse_mode = 1;
	while(1) {
		vec_set( mouse_pos, mouse_cursor );
		wait(1);
	}
}


No need for the wait after sys_exit.
Posted By: gamingfan101

Re: Why wont this work? - 06/10/09 18:54

wait, would i create it using a paint program? and what code would i use?
Posted By: Joozey

Re: Why wont this work? - 06/10/09 18:55

I edited my post.
Posted By: gamingfan101

Re: Why wont this work? - 06/10/09 19:09

Well, i used the code, but it still doesnt work. Here's the full code im using.


////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
////////////////////////////////////////////////////////////////////

BMAP* firebackground = "awesome-fire-dragon-ablaze.jpg"; // dragon fire background with button on it

PANEL* first_pan = // my first panel
{
pos_x = -40;
pos_y = 0;
layer = 1;
bmap = firebackground;
button(300, 0, "stopclicked.jpg", "stopnormal.jpg", "stopnormal.jpg", quit_program, NULL, NULL);
flags = OVERLAY | VISIBLE;
}
BMAP* pngRobot = "LDDScreenShot1.png"; // robot in foreground

PANEL* second_panel =
{
pos_x = -270;
pos_y = -100;
layer = 2;
bmap = pngRobot;
flags = OVERLAY | VISIBLE;
}

/////////////////////////////////////////////////////////////////////

function main()
{
video_mode = 7;
screen_color.red = 100;
}

function mouse()
{
mouse mode = 1;
while (1);
{
vec_set(mouse_pos, mouse_cursor);
wait(1);
}
}


function quit_program()
{
while (key_any) {wait (1);}
sys_exit(NULL);
}
Posted By: EvilSOB

Re: Why wont this work? - 06/10/09 19:31

try changine
sys_exit(NULL);
to be
sys_exit("");

If that doesnt help, put a beep(); into "quit_program"
to see if the button is even registering the click.
Can you see button image change from "stopclicked.jpg" to "stopnormal.jpg"
when the mouse hovers over it?
Posted By: gamingfan101

Re: Why wont this work? - 06/10/09 19:47

no, i cant see any change, i dont know what im doing wrong. the button shows up, but i cant click it or anything.
Posted By: EvilSOB

Re: Why wont this work? - 06/10/09 19:57

Try commenting out the definition of "second_panel" as a test.

Also what version of 3DGS are you using?
If you are using A7.63 or higher, you should be using the
SHOW flag on the panels, not VISIBLE as it was changed to SHOW in A7.63

[EDIT] Hehehe, good point Joozey. I didnt notice that the mouse never
gets turned on cause the mouse action is never actually called...
Posted By: Joozey

Re: Why wont this work? - 06/10/09 19:58

How about calling the mouse function first wink
Posted By: gamingfan101

Re: Why wont this work? - 06/10/09 20:04

the mouse function has been called hasnt it?


function mouse()
{
mouse mode = 1;
while (1);
{
vec_set(mouse_pos, mouse_cursor);
wait(1);
}
}
Posted By: KiwiBoy

Re: Why wont this work? - 06/10/09 20:08

Try function mouse_startup(; so that it starts before the script or set inside of main to call up before the script needs it, then the mouse will be 'on' and you can click!
Posted By: gamingfan101

Re: Why wont this work? - 06/10/09 20:19

Well, now the engine wont start the script. Heres the full code.


////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
////////////////////////////////////////////////////////////////////


BMAP* firebackground = "awesome-fire-dragon-ablaze.jpg"; // dragon fire background with button on it

PANEL* first_pan = // my first panel
{
pos_x = -40;
pos_y = 0;
layer = 1;
bmap = firebackground;
button(300, 0, "stopclicked.jpg", "stopnormal.jpg", "stopnormal.jpg", quit_program, NULL, NULL);
flags = OVERLAY | VISIBLE;
}
BMAP* pngRobot = "LDDScreenShot1.png"; // robot in foreground

PANEL* second_panel =
{
pos_x = -270;
pos_y = -100;
layer = 2;
bmap = pngRobot;
flags = OVERLAY | VISIBLE;
}

/////////////////////////////////////////////////////////////////////

function main()
{
video_mode = 7;
screen_color.red = 100;
}

function mouse_startup()
{
mouse_mode = 1;
while (1);
{
vec_set(mouse_pos, mouse_cursor);
wait(1);
}
}


function quit_program()
{
while (key_any) {wait (1);}
sys_exit("");
}
Posted By: KiwiBoy

Re: Why wont this work? - 06/10/09 20:27

What about this?
"awesome-fire-dragon-ablaze.jpg"
I havnt ever seen a def like this before, shouldnt it be;
'awesome_fire_dragon_ablaze.jpg' as I amnot sure if the syntax is readable or even permitted.

[edit] Wooopsies...and you dont actually have a level loading up do you ? In main;
level_load = " ???"'
Posted By: gamingfan101

Re: Why wont this work? - 06/10/09 20:34

awesome-fire-dragon-ablaze.jpg is the name of the image, and that image works fine. and im still new to all this so i dont actually have a level, its just a picture with a button to end the program. Similar to workshop 06.
Posted By: EvilSOB

Re: Why wont this work? - 06/10/09 20:38

Then just change main to be this...
Code:
function main()
{
video_mode = 7;
level_load("");
screen_color.red = 100;
}


And if it STILL doesnt go, whats the name of your file?
Make sure its saved as somthing.C and not wdl.
And what is the error message that it spits up when it fails?
If you dont get one, go into SED/Options/Preferences/ and delete
the -eq out of the command-line options and try again.
Posted By: alibaba

Re: Why wont this work? - 06/10/09 20:59

as i said you must remove:
while (key_any) {wait (1);}
Posted By: gamingfan101

Re: Why wont this work? - 06/10/09 21:39

ok, heres the new code, for some reason now it takes forever to load, and when it does the screen is just black, What am i missing? Im really sorry for bugging you all with this.

////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
////////////////////////////////////////////////////////////////////


BMAP* firebackground = "awesome-fire-dragon-ablaze.jpg"; // dragon fire background with button on it

PANEL* first_pan = // my first panel
{
pos_x = -40;
pos_y = 0;
layer = 1;
bmap = firebackground;
button(300, 0, "stopclicked.jpg", "stopnormal.jpg", "stopnormal.jpg", quit_program, NULL, NULL);
flags = OVERLAY | VISIBLE;
}
BMAP* pngRobot = "LDDScreenShot1.png"; // robot in foreground

PANEL* second_panel =
{
pos_x = -270;
pos_y = -100;
layer = 2;
bmap = pngRobot;
flags = OVERLAY | VISIBLE;
}

/////////////////////////////////////////////////////////////////////

function main()
{
video_mode = 7;
level_load("");
screen_color.red = 100;
}


function mouse_startup()
{
mouse_mode = 1;
while (1);
{
vec_set(mouse_pos, mouse_cursor);
wait(1);
}
}

Posted By: Joozey

Re: Why wont this work? - 06/11/09 00:23

You still don't call the mouse function (with the previous code).

function main()
{
...
mouse();
}
Posted By: alibaba

Re: Why wont this work? - 06/11/09 10:14

he has _startup() at the name.that means it starts automatically
here i correct and tested it:
////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
////////////////////////////////////////////////////////////////////
function quit_program()
{
sys_exit("");
}

BMAP* firebackground = "awesome-fire-dragon-ablaze.jpg"; // dragon fire background with button on it

PANEL* first_pan = // my first panel
{
pos_x = -40;
pos_y = 0;
layer = 1;
bmap = firebackground;
button(300, 0, "stopclicked.jpg", "stopnormal.jpg", "stopnormal.jpg", quit_program, NULL, NULL);
flags = OVERLAY | SHOW;
}
BMAP* pngRobot = "LDDScreenShot1.png"; // robot in foreground

PANEL* second_panel =
{
pos_x = -270;
pos_y = -100;
layer = 2;
bmap = pngRobot;
flags = OVERLAY | SHOW;
}

/////////////////////////////////////////////////////////////////////
BMAP* arrow = "arrow.bmp";

function mouse_toggle() // switches the mouse on and off
{
mouse_map = arrow; // use arrow as mouse pointer
if (mouse_mode >= 2) { // was it already on?
mouse_mode = 0;
} else {
mouse_mode = 2;
}
while (mouse_mode > 0) // move it over the screen
{
vec_set(mouse_pos,mouse_cursor);
wait(1);
}
}
function main()
{
video_mode = 7;
screen_color.red = 100;
mouse_toggle();
}


Posted By: Joozey

Re: Why wont this work? - 06/11/09 18:47

Well, startup didn't work for me while adding into the main did. So aparantly it doesn't start in all cases wink.
Posted By: alibaba

Re: Why wont this work? - 06/11/09 20:34

ah ok sorry. but now the code should work and i didnt use _startup
Posted By: gamingfan101

Re: Why wont this work? - 06/11/09 21:02

oh ok, i got it working now, thanks! im sorry for bugging you all with these questions, but can you please help me with two more things. One, in my program ive got the button set to OVERLAY but the black outside still shows up, any ideas? And two, what does it mean when the engine says "invalid slider size"?
Posted By: alibaba

Re: Why wont this work? - 06/11/09 21:08

first of all:
use bitmaps and not jpg or png.
second:
i think your slider ist to big or to small.
Posted By: gamingfan101

Re: Why wont this work? - 06/11/09 21:10

you mean the slider bitmap is too big or small, or the slider itself? Because i created it in the program Paint if that affects anything.
Posted By: EvilSOB

Re: Why wont this work? - 06/11/09 22:56

Not the bitmaps, the size its talking about is your sliders range.
Its either the MIN, MAX, or VAR values that are bad.

"min" MUST be zero or higher. Negatives not allowed.
"max" MUST be higher than "min"
"var" MUST be between, or equal to, either "min" or "max"
© 2024 lite-C Forums