Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,382 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
the cusor code is crashing? Why? #132433
05/28/07 07:41
05/28/07 07:41
Joined: May 2006
Posts: 132
Norway
Fiskekona Offline OP
Member
Fiskekona  Offline OP
Member

Joined: May 2006
Posts: 132
Norway
I am using this code for my moorhuhn like game. it allows me to use the mouse to slide the game screen from side to side using the mouse or the arrow keys.
The code is behaving just like I want to , and havent causing me any troubles until I started to test the game for more than 2 minutes. I have a counter that gives the player 3 minutes, and if you find it you can get 30 seconds more... Well it is working fine!

The problem is : When I have been playing for a while...maybe 2-5 minutes then I get this error:

crash in init_cusor_support ; wait(1)

How come? Why does it crash? What am I doing wrong?


Code:
 // ----------------------------------------------------------------------------
// BMAPS:

bmap crosshair_map = <crosshair.tga>;


// ----------------------------------------------------------------------------
// VARS:

var scrborder_size = 50;
//Sets the range at the side of the screen where scrolling starts, default = 20

var scroll_speed = 20;//original 20
//speed of scrolling, default = 10

var level_borders[2] = -4000,4000;//original -512,512
//how far the camera can slide in x direction, default: -512,512

//var time_step = 2;
// ----------------------------------------------------------------------------
// FUNCTIONS:

//her blir kameraet som følger musepekeren laget//
function move_camera()
{
var i;

while(1)
{
i = int((pointer.x - (screen_size.x / 2)) / ((screen_size.x / 2) - scrborder_size));
camera.x = clamp(camera.x + i * scroll_speed * time,level_borders[0],level_borders[1]);

wait(1);
}
}

//muse pekeren blir satt her slik at den får et sikte//
function set_mouse(_mode)
{
mouse_mode = _mode;
mouse_map = crosshair_map;
mouse_range = 100000;//dette har jeg lagt til//original 5000
mouse_spot.x = bmap_width(crosshair_map) / 2;
mouse_spot.y = bmap_height(crosshair_map) / 2;

while(mouse_mode)
{
mouse_pos.x = pointer.x;
mouse_pos.y = pointer.y;
mouse_pos.x = clamp(mouse_pos.x,0,screen_size.x - bmap_width(crosshair_map));
wait(1);
}
}

//-------her har jeg lagt til (med hjelp) høyre og ventsre piltast//
//-------slik at jeg kan scrolle bildet frem og tilbake med piltastene//
var cursor_move; //added!
function move_camera2()
{
var i;
while(1)
{
i = int((pointer.x - (screen_size.x / 2)) / ((screen_size.x / 2) - scrborder_size));
camera.x = clamp(camera.x + (i + cursor_move) * scroll_speed * time,level_borders[0],level_borders[1]); //changed!
init_cursor_support();
wait(1);
}
}

//her blir piltastene kalt//

function init_cursor_support()
{
while(1)
{
cursor_move = (key_cur - key_cul); <-- its here i get the crash
wait(1); <-- and here
}
}



function init_mouse_2()
{
set_mouse(2); //set the mouse_mode to 2
move_camera(); //now let the camera move
move_camera2();//kamera til piltastene

}




Programmer in training... Own GameStudio Commerical 6.50
Re: the cusor code is crashing? Why? [Re: Fiskekona] #132434
05/28/07 09:32
05/28/07 09:32
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline
Serious User
jigalypuff  Offline
Serious User

Joined: Nov 2005
Posts: 1,007
while(mouse_mode)
{
mouse_pos.x = pointer.x;
mouse_pos.y = pointer.y;
mouse_pos.x = clamp(mouse_pos.x,0,screen_size.x - bmap_width(crosshair_map));
}
wait(1);

put the wait there, i think.


Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: the cusor code is crashing? Why? [Re: jigalypuff] #132435
05/28/07 09:42
05/28/07 09:42
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Are you overloading the 'stack' by adding new functions which never exit?
while -> add function which never exits


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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