Page 1 of 2

Help with mouse pointer problem - PIC & .ged included.

PostPosted: Thu Apr 19, 2007 2:52 pm
by scythe
Here is an example of what id like to do

http://img111.imagevenue.com/img.php?im ... _529lo.jpg

I want the mouse pointer to act as the crosshair and to stay in the middle of screen but the rest of the background to move within the green area when mouse is moved. I then want to be able to click the mouse or press button when the 4 pixel red cursor is over the blue cans and destroy them when i do this. Ive wasted so much time trying to get this to work, can anyone help?



Thanks,
Scythe

PostPosted: Thu Apr 19, 2007 6:20 pm
by pixelpoop
add an event to the view actor (the white bounding box)
(add-> create actor ->follow mouse)

parent the cross hairs actor to the view

add a new actor with a type of canvas

stretch the canvas to the size of the white box. (this is going to catch the mouse down button)

on the canvas actor go events add-> mousbuttondown ->script editor

create a new Global Integer Variable with the variable button (i called mine yourglobalvariablename)

in the scripting window type: yourglobalvariablename=1;

click add -> imediate action

now add a mouse up script editor event and type yourglobalvariablename=0;

on your actor to be shot go events -> add -> oncollision of crosshairs (change no to yes for repeat action) ->script editor and type this:

if (yourglobalvariablename==1)DestroyActor("Event Actor");

now test

PostPosted: Fri Apr 20, 2007 9:28 pm
by Sgt. Sparky
got to em' before I could. :(

PostPosted: Sat Apr 21, 2007 8:20 am
by scythe
Thanks, i tried it, but am having the same problem as ive had a few times before, it seems to just scroll off the screen, here is my .ged file included.

I just want the dot to be able to kill the guy (testposer) i included in the .ged when i click on it, also i'd like to be able to do the same thing with keys, like make the dot kill the guy when button A is pressed for example.

Scythe

PostPosted: Sat Apr 21, 2007 4:44 pm
by Sgt. Sparky
okay, I will work on it :)

but here is an example code,
first make a variable called slash,
on the key down event of A for your player,
Code: Select all
slash = 1;

on the key up event of A for your player,
Code: Select all
slash = 0;

now add this event for the you're player when it collides with the enemy,
Code: Select all
if(slash == 1)DestroyActor("Collide Actor");

do ya' get what I mean? :D

PostPosted: Tue Apr 24, 2007 4:27 pm
by scythe
I tried it, but could not get it to work, so I started from scratch and did this...

Script / Global codes / Variables / Add
and created the variable Slash

Actor Control / Player / Key Down / A / Script editor
slash = 1;

At this point i get this error:

Error Line 1: Incompatible types: cannot convert from 'const int' to 'identifier' etc.

I didnt get this error the first time i tried, I must have stuffed up somewhere, sorry for being a lamer btw, but I am uber noob at any scripting/coding other than very basic html, so thanks for your help.

But i kinda understand what you mean and this has helped me learn a little along with the demo .geds.

scythe

PostPosted: Tue Apr 24, 2007 4:32 pm
by Sgt. Sparky
okay,
if the variable is slash use slash = 1;
if it is Slash use Slash = 1;
you must match capitals exaclty :)
and when that key is pressed use,
Code: Select all
if(slash == 0)ChangeAnimation("Event Actor", "your_attack animation", FORWARD);

and when your attack animation finishes
Code: Select all
slash = 0;

:D
if you need more help let me know,
I used to be new at this to ya' know. :D

PostPosted: Tue Apr 24, 2007 5:31 pm
by scythe
Thanks for the help, cant believe I missed the case sensitive error hehe :)

Anyway sorry to bother you again but I still cannot get it working :( , could you possibly add that code to the demo .ged file i attached and up it, as it may be easier for me to work it out by examining the .ged file. The demo .ged file is basic, but should show you what i'm upto, well actually this sniper type game is what I hope to do after my first duck shooting gallery game attempt :)

Thanks again,
Scythe

PostPosted: Tue Apr 24, 2007 5:35 pm
by Sgt. Sparky
win rar is not installed... :(
could you make it a .zip? :)

PostPosted: Tue Apr 24, 2007 6:08 pm
by scythe
Sure no prob, just had to install it on my Vista partition, here is the .zip attached.

Thanks,
Scythe

PostPosted: Tue Apr 24, 2007 6:42 pm
by pixelpoop
list of problems:

on the "a" key up event you need to set Slash back to 0. You were setting it as 1.

I don't think your red dot ever touches the man because the sniperview actor is inbetween them.

Your collision statement is incomplete. you wrote: if(Slash==1);
it should read something like this:
if(Slash==1)DestroyActor("NME_Terrorist");

think of "if" statements as "if then" or "if then else"...
if (this is true){ then do this; and this;} else {do this if the statement is not true;}

you should also have the collision statement on the man. that way if you have clones of the same guy you won't kill them all with the same bullet.

Your fire button should not be set to repeat unless the gun shoots at 30 bullets per second

on the Draw Actor event for the red dot I included this code:
if (n==1) { n=0; Slash=0; }
if (Slash==1) n=1;

note: that code makes it so you can't press the fire button and then drag the view over the man. The kill only lasts 1 frame.

i have included these changes in this file.

PostPosted: Fri Apr 27, 2007 8:31 am
by scythe
Thanks pixelpoop I'll make sure you and sgt sparky and other guys that help get a mention in the credits, if i ever get time to finish it :)

Yeah sorry about that, the code was messy as i was half assed editing it too see if i could find out what the problems were, and kinda left it half edited :)

I'll study your stuff and hopefully it will help me understand things a little more, I used to program a little basic on the c64 in the late 80's but seem to have forgotten everything like IF THEN etc. :)

I cant seem to get the player reddot to sway with the scope by using parent though, as it then effects the background, i'll look into it, but I probably was gonna scrap that part anyway as i couldnt get it to look quite right and don't need it for the Duck & Can shooting game.

BTW I can't seem to get on the forum sometimes, but can visit the GE main page, anyone else have that problem? must be getting busy i guess.

Thanks again guys,
scythe

PostPosted: Fri Apr 27, 2007 2:18 pm
by Sgt. Sparky
scythe wrote:BTW I can't seem to get on the forum sometimes, but can visit the GE main page, anyone else have that problem? must be getting busy i guess.

yeah,
I could not get on the forum untill just a few minutes ago,
it would not even let me onto the GE main page.... :(
internet explorer cannot display the webpage....
worst message I got... :(

PostPosted: Fri Apr 27, 2007 2:51 pm
by Caaz Games
Sgt. Sparky wrote:
scythe wrote:BTW I can't seem to get on the forum sometimes, but can visit the GE main page, anyone else have that problem? must be getting busy i guess.

yeah,
I could not get on the forum untill just a few minutes ago,
it would not even let me onto the GE main page.... :(
internet explorer cannot display the webpage....
worst message I got... :(
Same for me except I'm using Firefox and it says it cannot connect.

PostPosted: Fri Apr 27, 2007 6:09 pm
by Sgt. Sparky
__CAAZ__'s signature wrote:I'm Going To Be On T.V.!

why? :|