Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,187 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Help with buttons #245894
01/12/09 16:12
01/12/09 16:12
Joined: Jul 2008
Posts: 26
Norway
H
Harstad Offline OP
Newbie
Harstad  Offline OP
Newbie
H

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 Offline
Expert
Cowabanga  Offline
Expert

Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
change function quit_program to this:
Code:
function quit_program()
{
     sys_exit(NULL);
}


and change function main to this:
Code:
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:
Code:
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
H
Harstad Offline OP
Newbie
Harstad  Offline OP
Newbie
H

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 Offline
Senior Member
Mr Wurm  Offline
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

Re: Help with buttons [Re: Mr Wurm] #246261
01/14/09 11:48
01/14/09 11:48
Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Cowabanga Offline
Expert
Cowabanga  Offline
Expert

Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Yeah! I've forgot!

Code:
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;
          wait(1);
     }
}



Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1