|
Help with buttons
#245894
01/12/09 16:12
01/12/09 16:12
|
Joined: Jul 2008
Posts: 26 Norway
Harstad
OP
Newbie
|
OP
Newbie
Joined: Jul 2008
Posts: 26
Norway
|
HI, first of all, I'm new to this.
well, as you might guess, I'm here to ask you to help me. I'm going through the workshop and made some panels and tried to add a button, but I can't seem to get to press the button.
well, here's the code:
#include <acknex.h> #include <default.c>
function main () { video_mode = 7; screen_color.blue = 150; mouse_mode = 4; }
BMAP* background = "second.bmp"; BMAP* gras = "gress.bmp";
PANEL* new_background = { pos_x = 0; pos_y = 0; bmap = background; layer = 1; flags = VISIBLE; }
PANEL* new_ground = { pos_x = 0; pos_y = 0; bmap = gras; button (10, 10, "button_clicked.bmp", "button_unpressed.bmp", "button_pressed.bmp", quit_program, NULL, NULL); layer = 2; flags = OVERLAY | VISIBLE; }
function quit_program() {
while (key_any) {wait (1);} sys_exit (NULL); }
|
|
|
Re: Help with buttons
[Re: Harstad]
#245900
01/12/09 16:25
01/12/09 16:25
|
Joined: Aug 2008
Posts: 2,838 take me down to the paradise c...
Cowabanga
Expert
|
Expert
Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
|
change function quit_program to this: function quit_program()
{
sys_exit(NULL);
} and change function main to this: function main()
{
video_mode = 7;
screen_color.blue = 150;
mouse_mode = 2;
mouse_map = mouse_bmap;
while(1)
{
mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;
}
} and add this line in your script: BMAP* mouse_bmap = "mouse.pcx"; (replace "mouse.pcx" by your cursor sprite)
|
|
|
Re: Help with buttons
[Re: Cowabanga]
#245918
01/12/09 17:09
01/12/09 17:09
|
Joined: Jul 2008
Posts: 26 Norway
Harstad
OP
Newbie
|
OP
Newbie
Joined: Jul 2008
Posts: 26
Norway
|
I changed it to this, as you said: But now it hangs up when I try to compile it:P guess its not my day:P
#include <acknex.h> #include <default.c>
BMAP* mouse_bmap = "mouse.bmp"; BMAP* background = "second.bmp"; BMAP* gras = "gress.bmp";
PANEL* new_background = { pos_x = 0; pos_y = 0; bmap = background; layer = 1; flags = VISIBLE; }
PANEL* new_ground = { pos_x = 0; pos_y = 0; bmap = gras; button (10, 10, "button_clicked.bmp", "button_unpressed.bmp", "button_pressed.bmp", quit_program, NULL, NULL); layer = 2; flags = OVERLAY | VISIBLE; }
function quit_program() { sys_exit (NULL); }
function main () { video_mode = 7; screen_color.blue = 150; mouse_mode = 2; mouse_map = mouse_bmap; while (1) { mouse_pos.x = mouse_cursor.x; mouse_pos.y = mouse_cursor.y; } }
though, if I take away the while (1) { mouse_pos.x ....... mouse_cursor.y;} it works fine, but I can't move the mouse inside the game:P:P
may there be an issue with vista32?
Last edited by Harstad; 01/12/09 17:14.
|
|
|
Re: Help with buttons
[Re: Harstad]
#246009
01/13/09 00:25
01/13/09 00:25
|
Joined: Jul 2002
Posts: 446 Switzerland
Mr Wurm
Senior Member
|
Senior Member
Joined: Jul 2002
Posts: 446
Switzerland
|
naw no issue with vista, you have just created an endless loop... while(1) <-until killed { perform this and this wait(1); <-pause for a frame, to allow all the other functions to work and to allow the engine to render etc. }
So: insert a wait(1); at the end of the while(1) loop and it will cease to crash and start to work.
- Mr Wurm
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|