Gamestudio Links
Zorro Links
Newest Posts
Fun Arcade Car Physics (nfs style)
by rayp. 07/25/26 00:35
What are you working on?
by rayp. 07/24/26 22:58
Z9 getting Error 058
by madpower2000. 07/22/26 14:01
ZorroGPT
by TipmyPip. 07/21/26 17:54
New Zorro version 3.11
by jcl. 07/21/26 13:42
Lapsa's very own thread
by Lapsa. 07/18/26 13:40
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (Quad), 1,852 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
riggi89, shuhari, KD1990, Ephraim, Student_64151
19223 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Mouse Check #138789
06/29/07 11:40
06/29/07 11:40
Joined: Jun 2007
Posts: 8
H
hammeraxe Offline OP
Newbie
hammeraxe  Offline OP
Newbie
H

Joined: Jun 2007
Posts: 8
Hi!

My problem is that I cant create a well-working code to check if the mouse has clicked a building and if it is to show its menu. The properties of all buildings are stored in an array buildings[400]. My function first checks the location of the mouse (works good) and then tries to find it in the building array. Then it recrods the number of the building and calls another function to display the menu.

The problem is that it works only sometimes...

Code:

function check
{
var a=0;
var found=0;
if((mouse_ent!=0)&&(mouse_ent!=MainObject)&&(mouse_ent!=PointerSquare))
{
NodeDetect();//returns x= the location of object
temp=x;
a=0;
found=0;
while(a<=99)&&(found==0)
{

if(temp==buildings[a])//buildings[a] stores the position of every building
{
found=1;
found_no=a;

}

if(a<99)&&(found==0)
{
a+=1;
}

wait(1);
}
}
if(found==1)&&(buildings[found_no+100]==0){ show_menu();} //checks if the building is still under construction
if(found==1)&&(buildings[found_no+100]>0){ show_constr();}
}

Re: Mouse Check [Re: hammeraxe] #138790
06/29/07 13:03
06/29/07 13:03
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline
User
demiGod  Offline
User

Joined: Mar 2006
Posts: 752
Portugal
With a brief view of your code (no time for more) i can thing about two things:

1) check your mouse_range maybe needs to be increased

2) where did you get the temp=x ? "x" its reserved for the engine, change it with other name, and i advice you to give meaning names to the variables and functions


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

Gamestudio download | 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