|
Hmmm. . . why isn't this. . .? Displaying 1-13 of 13 total.
1
CypherAlmasy
|
I'm a newbie, and I've got a minor problem. I'm trying to write some code that will allow a person to click on a character to select them. Unfortunately, I'm having trouble getting the engine to store some values to some variables; namely, it won't do anything with mx and my. Also, I have no idea if I'm using the entity.x and entity.y variables correctly; could someone help me out with those, too? If necessary, I'll share my code, but does anyone know what the problem is right off the bat? Thank you in advance.
CypherAlmasy
"Seeing Ingmar the Holy Paladin rapping is a little out of place in a religious/medieval setting, unless he has a *damned* good reason."
-McGrue, "Maintaining an Illusion"
Posted on 2001-09-08 22:30:08
|
Roto
|
(nt)
Posted on 2001-09-08 23:26:26
|
CypherAlmasy
|
If I'm not wrong (and I doubt that I am), I'm using Verge 2.01, I believe it's the first release. My internet connection speed is monstrously slow, and I don't have the capability to stay on for very long, so I use what I can get my hands on. I my be updating to Verge 2.6 pretty soon, though.
Posted on 2001-09-08 23:42:46
|
Roto
|
Just how you are going about and doing this? No need to show off your total source. Just the relevant function.
By the way, sorry for the delay, I tend not to really check these boards as often as I used to.
Posted on 2001-09-09 05:01:49
|
andy
|
Something that comes to mind is that entity.x and entity.y are relative to the upper left corner of the map. (in pixels)
mx and my are in screen coordinates. If you want to detect whether an entity is under a cursor, then you simply subtract xwin and ywin from entity.x and entity.y
int ex,ey;
int i;
for (i=0; i<numents; i++)
{
ex=entity.x[i]-xwin;
ey=entity.y[i]-ywin;
if (cursorisoverentity(ex,ey,mx,my)) // I'll let you write this one yourself. :)
{
// do your thing
}
}
"Ignorance is its own reward" -- Proverb
Posted on 2001-09-09 10:56:36
|
CypherAlmasy
|
Here's the function I'm using to display the mouse pointer, though slightly mangled from its original form from the feeble attempts I made to correct the error. In theory (by my view), the while loop should update the variables 'x' and 'y' every time the loop executes, which would keep a running tab on the location of the mouse. When the mouse button is pressed, the x and y coordinates of the mouse are checked (via the last update of x and y) and then checked against the position of the only entity on the screen (this is only a test of my plan, later I'll update it for multiple entities), and if they match the sound is played. The only problem is, whenever I click nothing happens. Using the console to check the values of 'x' and 'y', I find that both are somehow equal to zero, as if the engine never updated them while it was running. Both 'x' and 'y' are declated in system.vc, so I don't think it's a scope problem (can you declare vars in .vc files besides system.vc?). My closest guess would be that the division is throwing off the engine, because both 'x' and 'y' are ints. However, if the vars work like they do in actual C++, then the decimal part should just be truncated, right? Also, I have no idea how to use 'entity.x' and 'entity.y', so I've been treating them as arrays. If you wouldn't mind telling me how they really work, I would be very thankful. Sorry for talking on like that, I was just trying to get you a glimpse into my mind's processes. Thank you in advance for all of your help. And now, without further ado, my source code.
void MouseControl()
{
LoadFont("system.fnt");
pointer = LoadImage("pointer2.pcx");
SetMousePos(50,50);
while(!(mb & 1))
{
Render();
TCopySprite(mx, my, 24, 20, pointer);
ShowPage();
ReadMouse();
x = mx/screenx;
y = my/screeny;
}
ReadMouse();
TCopySprite(mx, my, 24, 20, pointer);
ShowPage();
// x = mx/screenx;
// y = my/screeny;
charx = entity.x[character]/screenx;
chary = entity.y[character]/screeny;
if(x=charx && y=chary)
{
PlaySound(sephSound,63,128);
}
Thanks again.
CypherAlmasy
Co-President/Head Programmer, Split Infinity Productions.
Life is an RPG. How much experience have you earned?
Posted on 2001-09-11 01:25:13
|
CypherAlmasy
|
Of course! mx and my are always going to be less than screenx and screeny, so when the division takes place, the decimal part is truncated, leaving a value of 0! I actually said it in my big rant up there! I've got the frickin' variables backwards! ::hits head against wall repeatedly:: Ugh. Will it work if I change things around (i.e. does variable division truncate decimal parts like real C?) Thanks for your help. Now, I've got a few more problems.
I managed to download Verge 2.6 on to this computer (running Win2k), but I'm having some problems compiling. Whenever I run VCC, it gives me the following error (or something very much like it):
stub exec failed:
dos4gw - no such file or directory
What exactly does this mean, and how do I fix it? I searched all of my local drives for a file named dos4gw, but I couldn't find one. (That's probably going to sound really stupid once I find out what the problem really is. Oh well.)
Also, on my other computer (Win98), quitting Verge 2.01 using the exit command always causes some sort of General Protection fault. Usually, I can continue after that, but it sometimes causes my sound card to. . . how do I explain this? My speakers buzz horribly, and I can't run any other audio applications because the hardware is in use by another program. Is this a Verge thing, or is my comp just screwed up?
Once again, a million thanks for your help.
CypherAlmasy,
Co-President/Head Programmer, Split Infinity Productions.
Life is an RPG. How much experience have you earned?
Posted on 2001-09-11 01:38:24
|
CypherAlmasy
|
Thank you very much, TSB. I'll try this one out once I manage to get my compiler working.
CypherAlmasy
Life is an RPG. How much experience have you earned?
Posted on 2001-09-11 01:55:33
|
CypherAlmasy
|
I'm sorry I have so much to ask, it's just that as I keep working I keep stumbling on more stuff. Quick question: How would you test to see if either mouse button is pressed? I looked at Aen's tutorial on the subject, but to no avail. I tried the following code snippet:
if((mb & 1) || (mb & 2))
{
stuff
}
. . . but it only worked if BOTH mouse buttons were pressed. I know nothing about these "bitfields" that Aen refers to, so would someone mind just telling me how to do this as if I were a five-year old? Thank you.
CypherAlmasy
Co-President/Head Programmer, Split Infinity Productions
Life is an RPG. How much experience have you earned?
Posted on 2001-09-11 02:42:05
|
Roto
|
Hmmm, try dividing by 16 instead of screenx, screeny.
Seeing how each tile has 16 pixels each and the usual character width is 16 pixels, it makes sense and oughta work. By the way, you also have to give control of the character the player via the SetPlayer function, but I assume you're already doing that...
Posted on 2001-09-11 16:46:22
|
Roto
|
Don't know what you really mean by trucanting but if I'm thinking correctly, decimals are not supported in Verge2-2.6. You can get by without them though (if you utilize the proper math).
For the problems with DOS4GW, you just need to download DOS4GW and dump it into your windows directory. It ain't hard to find, a simple search should get you a link.
Verge's problems depend on the version. With V2K or earlier (excluding v2+i), it's probably your hardware's fault. Those versions of Verge worked perfectly under Win98 with my old hardware. Anything later (and before v2.7) was hilariously buggy.
Posted on 2001-09-11 16:58:31
|
Roto
|
Remove whatever button that doesn't need to be pressed.
For example, if the first button is what you need, just type...
if((mb & 1))
{
stuff
}
Posted on 2001-09-11 17:06:31
|
CypherAlmasy
|
Mwa ha ha ha! Mil gracias, senor. I'll probably have a lot more problems later on, but for now I think I'm in the green. Both you and the_Speed_Bump have been a great help. Thank you very much.
CypherAlmasy
Co-President/Head Programmer, Split Infinity Productions
Life is an RPG. How much experience have you earned?
Posted on 2001-09-11 21:05:20
|
Displaying 1-13 of 13 total.
1
|
|