Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Moving a thing to a vector.
Moving a thing to a vector.
2002-12-23, 5:57 PM #1
Well, I was originally intending to ask this in a more of a cloak-and-dagger manner, but I might as well not, as I suppose I'll receive better help if I'm clearer.

Code:
# menu.cog
#
#
# [Grismath]
#======================================================================================#
symbols
message		activated
message		playeraction
thing		screen
thing		camera
thing		cam0
thing		cam1
thing		cam2
thing		cam3
thing		mouse
int		curFrame=0	local
int		using=0		local
flex		tempflex	local
vector		tempvec		local
vector		tempvec2	local
vector		motionVector	local
end
#======================================================================================#
code
#--------------------------------------------------------
activated:
if(GetSenderRef()==screen) {
 SetCurrentCamera(0);
 SetCameraFocus(0, camera);
 using=1;
 SetActionCog(0, -1);
 SetActionCog(GetSelfCog(), 0x7FFFFFFF);
}
return;
#--------------------------------------------------------
playeraction:
if(using==1) {
 ReturnEx(0); 
 if(GetParam(0)==8) {
  if(GetParam(2)>0) {
	tempflex=2.8;
	motionVector = VectorSet(VectorX(motionVector), tempflex, VectorZ(motionVector));
  }
  if(GetParam(2)<0) {
  	tempflex=2.8;
	motionVector = VectorSet(VectorX(motionVector), -tempflex, VectorZ(motionVector));
  }
 }
 if(GetParam(0)==5) {
  if(GetParam(2)>0) {
	motionVector = VectorSet(GetParam(2), VectorY(motionVector), VectorZ(motionVector));
  }
  if(GetParam(2)<0) {
	motionVector = VectorSet(GetParam(2), VectorY(motionVector), VectorZ(motionVector));
  }
 }
 if(GetParam(0)==3) {
	print("Click");
	Sleep(0.2);
 }
tempvec = GetThingLVec(camera);
tempvec = VectorScale(tempvec, VectorZ(motionVector) / 3);
tempvec2 = GetThingUVec(camera);
tempvec2 = VectorScale(tempvec2, VectorY(motionVector) / 3);
tempvec = VectorAdd(tempvec, tempvec2);
tempvec2 = GetThingRVec(camera);
tempvec2 = VectorScale(tempvec2, VectorX(motionVector) / 3);
tempvec = VectorAdd(tempvec, tempvec2);
SetThingVel(camera, tempvec);
}
return;
#--------------------------------------------------------
end


THAT is a mouse-driven menu using playeraction.

The whole vector thing at the end is needless, methinks. I just copied that part over from the farsight cog. Once I had the playeraction down, I decided that I might model the mouse movement system off of farsight. The mouse, however, just disappears once I move it ingame. How would I move the mouse up, down, left, or right in a free form fashion?


[This message has been edited by Grismath (edited December 23, 2002).]
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2009-03-26, 7:10 AM #2
I can think of 2 ways of doing this. One being that the mouse is actually an explosion which you FireProjectile on a pulse. In playeraction you can add or subtract flex values (x,y) but only do so if they are within certain values (before leaving the view).
The other way, if you want the mouse to be a constant object, is to make it move with physics with something like ApplyForce. But only apply force if GetThingPos is within its limits. May need to fiddle with the template's mass and airdrag to have it not fly off to the other side of the level.

Hope this gives you some ideas. Oh, and remember that Y is not up/down. I also get confused around this. ;)

/Edward
Edward's Cognative Hazards

↑ Up to the top!