Gamestudio Links
Zorro Links
Newest Posts
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
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
3 registered members (AbrahamR, AndrewAMD, ozgur), 763 guests, and 7 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
Page 1 of 2 1 2
C# and Java Developer starting Lite-C programming. #293987
10/15/09 12:08
10/15/09 12:08
Joined: Oct 2009
Posts: 21
Redneck country USA
Crazykins Offline OP
Newbie
Crazykins  Offline OP
Newbie

Joined: Oct 2009
Posts: 21
Redneck country USA
Lite-C is coming pretty fast for me. But it seems I am at a stand still. I did look at all of the tutorials, manual, and the AUM for this information. What I am trying to do is to have a mouse click on a model 1. Trigger the mouse clicked event. 2. Find out which house was clicked. 3. Load the appropriate level. Here is my code thus far:
Code:
BMAP* cursor = "cursor.tga";
var frame_speed = 0;
STRING* mystring = "You clicked the mouse!";

function main()
{
    video_mode = 9;
    video_screen = 1;
    level_load ("level1.wmb");
    mouse_mode += 1;
    mouse_map = cursor;
    
    while (1)
   {
      mouse_pos.x = mouse_cursor.x;
      mouse_pos.y = mouse_cursor.y;
       
      wait (1);
   }
}

function house_event()
   {
     if (event_type == EVENT_TOUCH) // the house was touched?
     {
       my.ambient = 50; // make it look bright
       my.lightrange = 50; // and generate light on a radius of 50 quants!
       
       while (frame_speed <= 101)
       {
       	ent_animate(my, "Move", frame_speed, ANM_CYCLE);
         frame_speed += 8 * time_step;
         wait(1);
       }
       frame_speed = 0;
       
       if (event_type == EVENT_CLICK)
       {
       	TEXT* myText =
			{
			    pos_x = 300;
			    pos_y = 250;
			    string (myString);
			    flags = SHOW;
			}
       }
     }
     else // the house isn't touched anymore
     {
         if (event_type == EVENT_RELEASE) // the mouse was moved away from it?
         {
               my.ambient = 0; // then restore its initial ambient value (zero)
               my.lightrange = 0; // and stop it from generating light around it
         }
     }
   }
   
   action house_selection() // this action is attached to both houses
   {  
     // make the house models sensitive to mouse touching and releasing
     my.emask = ENABLE_TOUCH | ENABLE_RELEASE;
     my.emask |= ENABLE_CLICK;
     my.event = house_event; 
   }



The lighting and animation on the mouse over event works perfectly. I am trying to test the mouse click with a message. The message is always up even if there were no mouse hover or click events. Which to me is weird. Why would it even execute before the event. This could be because of my background in C# and Java that I am just not getting why this is happening. The events are setup correctly as you can plainly see from the code. I also tried different flags and tried using toggle keyword but still the message is always up.

I also need help finding the correct keyword in Lite-C to get an object (model) from a mouse position. I can find little of this in the manual. I have the express version of 3dgs.

Thanks for your help! laugh

Last edited by Crazykins; 10/18/09 08:35.
Re: C# and Java Developer starting Lite-C programming. [Re: Crazykins] #293988
10/15/09 12:21
10/15/09 12:21
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline
Serious User
pegamode  Offline
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
I think you have to use txt_create() to create a TEXT object at runtime.

I think there's some remark in the manual.

Regards,
Pegamode.


Last edited by pegamode; 10/15/09 12:22.
Re: C# and Java Developer starting Lite-C programming. [Re: pegamode] #294000
10/15/09 13:54
10/15/09 13:54
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!
Place the code for :TEXT* myText

outside the event
and comment out this line
// flags = SHOW;

Then you can set or reset this flags in another function wink


Hope this helps!
Ottawa laugh

Ver 7.86.2 Pro and Lite-C
Re: C# and Java Developer starting Lite-C programming. [Re: Ottawa] #294004
10/15/09 14:23
10/15/09 14:23
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline
Serious User
pegamode  Offline
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Originally Posted By: Ottawa
Hi!
Place the code for :TEXT* myText

outside the event
and comment out this line
// flags = SHOW;

Then you can set or reset this flags in another function wink




Yes, I forgot to mention this ... otherwise you would have to use txt_create.

Re: C# and Java Developer starting Lite-C programming. [Re: pegamode] #294060
10/15/09 21:47
10/15/09 21:47
Joined: Oct 2009
Posts: 21
Redneck country USA
Crazykins Offline OP
Newbie
Crazykins  Offline OP
Newbie

Joined: Oct 2009
Posts: 21
Redneck country USA
ok this time I put the myText object under the myString object. And I changed my nested if statement to:
Code:
if (event_type == EVENT_CLICK)
       {
       	myText.flags = SHOW;
       }



It is still nested in my house_event function. It is still not working. I must be doing something wrong I just can't figure out what it is. frown

I even tried this:

Code:
action house_selection() // this action is attached to both houses
   {  
     // make the house models sensitive to mouse touching and releasing
     my.emask = ENABLE_TOUCH | ENABLE_RELEASE | ENABLE_CLICK;
     my.event = house_event; 
   }


and re assigning the action in WED. Nothing works.

Thanks though for all of your help! laugh

Last edited by Crazykins; 10/18/09 08:36.
Re: C# and Java Developer starting Lite-C programming. [Re: Crazykins] #294066
10/15/09 23:29
10/15/09 23:29
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!

Your close wink

myText.flags = SHOW;
should be
myText.flags |= SHOW;

Look up the flags in the manual.
Look up set() reset() toggle ()
To help you with this part
pick up my contribution : Flags at a glance
in the resource section.


Hope this helps!
Ottawa laugh

Ver 7.86.2 Pro and Lite-C
Re: C# and Java Developer starting Lite-C programming. [Re: Ottawa] #294069
10/15/09 23:43
10/15/09 23:43
Joined: Oct 2009
Posts: 21
Redneck country USA
Crazykins Offline OP
Newbie
Crazykins  Offline OP
Newbie

Joined: Oct 2009
Posts: 21
Redneck country USA
I did finally get it to work! I had to take it out of my if statement nest for it to work. The working code is:
Code:
function house_event()
   {
     if (event_type == EVENT_TOUCH) // the house was touched?
     {
       my.ambient = 50; // make it look bright
       my.lightrange = 50; // and generate light on a radius of 50 quants!
       
       while (frame_speed <= 101)
       {
       	ent_animate(my, "Move", frame_speed, ANM_CYCLE);
         frame_speed += 8 * time_step;
         wait(1);
       }
       frame_speed = 0;
     }
     if (event_type == EVENT_CLICK)
     {
       	myText.flags |= SHOW;
     }
     else // the house isn't touched anymore
     {
         if (event_type == EVENT_RELEASE) // the mouse was moved away from it?
         {
               my.ambient = 0; // then restore its initial ambient value (zero)
               my.lightrange = 0; // and stop it from generating light around it
         }
     }
   }



For my function. Now that I have tested it comes the fun part of finding out which model the user clicks on. laugh

Last edited by Crazykins; 10/18/09 08:37.
Re: C# and Java Developer starting Lite-C programming. [Re: Crazykins] #294070
10/15/09 23:46
10/15/09 23:46
Joined: Oct 2009
Posts: 21
Redneck country USA
Crazykins Offline OP
Newbie
Crazykins  Offline OP
Newbie

Joined: Oct 2009
Posts: 21
Redneck country USA
SWEET! Thanks guys for all of your help! Using this code works super well.

Code:
if (event_type == EVENT_CLICK)
     {
       	toggle(myText, SHOW);
     }



Thanks once again!

Last edited by Crazykins; 10/18/09 08:37.
Re: C# and Java Developer starting Lite-C programming. [Re: Crazykins] #294073
10/16/09 00:30
10/16/09 00:30
Joined: Oct 2009
Posts: 21
Redneck country USA
Crazykins Offline OP
Newbie
Crazykins  Offline OP
Newbie

Joined: Oct 2009
Posts: 21
Redneck country USA
Thanks so much guys. Because of your help I was able to implement two actions and two entity objects to get which model was being selected by the user. Here is my code in case it may be able to help someone in the future. Thanks again! grin

Code:
ENTITY* houseOne;
ENTITY* houseTwo;
BMAP* cursor = "cursor.tga";
var frame_speed = 0;
STRING* myString_One = "You clicked on house one!";
STRING* myString_Two = "You click on house two!";
TEXT* myText_One =
			{
			    pos_x = 300;
			    pos_y = 250;
			    string (myString_One);
			}
TEXT* myText_Two =
			{
			    pos_x = 300;
			    pos_y = 250;
			    string (myString_Two);
			}

function main()
{
    video_mode = 9;
    video_screen = 1;
    level_load ("level1.wmb");
    mouse_mode += 1;
    mouse_map = cursor;
    
    while (1)
   {
      mouse_pos.x = mouse_cursor.x;
      mouse_pos.y = mouse_cursor.y;
       
      wait (1);
   }
}

function house_event()
   {
     if (event_type == EVENT_TOUCH) // the house was touched?
     {
       my.ambient = 50; // make it look bright
       my.lightrange = 50; // and generate light on a radius of 50 quants!
       
       while (frame_speed <= 101)
       {
       	ent_animate(my, "Move", frame_speed, ANM_CYCLE);
         frame_speed += 8 * time_step;
         wait(1);
       }
       frame_speed = 0;
     }
     if (event_type == EVENT_CLICK)
     {
       	if (houseOne == me)
       	{
       		toggle(myText_One, SHOW);
         }
         else
         {
         	if (houseTwo == me)
         	{
         		toggle(myText_Two, SHOW);
            }
         }
     }
     else // the house isn't touched anymore
     {
         if (event_type == EVENT_RELEASE) // the mouse was moved away from it?
         {
               my.ambient = 0; // then restore its initial ambient value (zero)
               my.lightrange = 0; // and stop it from generating light around it
         }
     }
   }
   
   action house_one_selection() // this action is attached to both houses
   {  
     // make the house models sensitive to mouse touching and releasing
     houseOne = me;
     my.emask = ENABLE_TOUCH | ENABLE_RELEASE | ENABLE_CLICK;
     my.event = house_event; 
   }
   
   action house_two_selection() // this action is attached to both houses
   {  
     // make the house models sensitive to mouse touching and releasing
     houseTwo = me;
     my.emask = ENABLE_TOUCH | ENABLE_RELEASE | ENABLE_CLICK;
     my.event = house_event; 
   }



Last edited by Crazykins; 10/18/09 08:38.
Re: C# and Java Developer starting Lite-C programming. [Re: Crazykins] #294119
10/16/09 13:32
10/16/09 13:32
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!

Happy to help laugh

Ottawa


PS : Here's something to read for posting.
In the FAQ read : What UBBCode can I use in my posts? wink

Last edited by Ottawa; 10/16/09 13:35.
Page 1 of 2 1 2

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