Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / arrow keys control question

Author
Message
i cant believe its not fabio
18
Years of Service
User Offline
Joined: 10th Feb 2006
Location:
Posted: 30th Jul 2007 11:05
i can't seem to use any of the following:



the compiler complains that the syntax is wrong:



here is my complete code:

i cant believe its not fabio
18
Years of Service
User Offline
Joined: 10th Feb 2006
Location:
Posted: 30th Jul 2007 11:07
also i'm having troouble with the shadows... they are not showing up.

They did at some point while i was working on the arrow keys code, but then i must have chenged something that messed it up...
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 30th Jul 2007 11:58
The evaluating function must be between "(" and ")".
Also "then" is not a reserved C/C++ word.

This is the right syntax:


Also all the commands at the main loop do not need to be executed every time (except dbSync() ).
i cant believe its not fabio
18
Years of Service
User Offline
Joined: 10th Feb 2006
Location:
Posted: 30th Jul 2007 12:29
Got it!

I googled a bit and found a piece of code that helped a lot, i worked around it a little since it was originally written to control a camera and achieved this:



Also the shadows now work for some reason...
Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 30th Jul 2007 16:09
there ya go!!

also, if you only have a single statement following the conditional, you can omit the braces...



... and save lil whitespace.

also, to make the code even more compact, this should work as well...



... although i'm not 100% sure, as i haven't tested it. but it should satisfy the overlap between logical and value equality...


--Mike
i cant believe its not fabio
18
Years of Service
User Offline
Joined: 10th Feb 2006
Location:
Posted: 30th Jul 2007 20:52
just tested it and it works great! I'll definitely use that approach when i need it.

Right now i'm just brainstorming different methods to see which one feels better for my game, i even thought about a point-and-click interface like in Fallout 1/2, with the character walking automatically to the clicked XZ coordinates while the camera follows with a slight momentum.
Chalkey
17
Years of Service
User Offline
Joined: 25th May 2007
Location:
Posted: 30th Jul 2007 21:05
Hey

A little point no one has made... In your original code post you used if dbRightKey ()=1 then.... In C++ the '=' symbol is the assign operator. This is used to assign a value of some sort to a variable... e.g. int x = 1;.

To compare variables you have to use the '==' operator. e.g. if (x == 1).

Hope this helps!
Chalk
i cant believe its not fabio
18
Years of Service
User Offline
Joined: 10th Feb 2006
Location:
Posted: 30th Jul 2007 21:18
great timing Chalkey!

This last one solved my compiling problem with this little snippet:



The only thing is... how do i make the movement smoother and relative to a 3D plane underneath the object to be moved upon mouse click, so that the object doesn't just disappear into oblivion?
unitech
17
Years of Service
User Offline
Joined: 27th Jun 2007
Location:
Posted: 31st Jul 2007 17:59 Edited at: 31st Jul 2007 18:00
Like Mike said, its best to use..

if (dbUpKey()) dbMoveObject (12,1.0);

Any thing in a () can be evaluated as true or false.

For example.

int r=1
if (r == 1) //do this..
same as
if (r) //do this. Since 0 would be false.

or

bool r=true
if (r) //do this.

In other words

if (anything in here evaluates true) // do this
i cant believe its not fabio
18
Years of Service
User Offline
Joined: 10th Feb 2006
Location:
Posted: 31st Jul 2007 18:11
thanks, i think i'm (slowly) getting it... the controls work ok now, and i started playing with dbPlayObject and dbLoopObject. I'm working on a few low poly crash test dummies to use but i don't quite seem to get the animation loop right, i started a thread about it here
i cant believe its not fabio
18
Years of Service
User Offline
Joined: 10th Feb 2006
Location:
Posted: 3rd Aug 2007 18:08 Edited at: 3rd Aug 2007 18:10
ok i gotta get back to this thread with a question about key combinations. Here is my problem:



The walk cycle works great for me but i would also like to be able, as the character walks, to switch to running by pressing the Shift key without letting go of the arrow...

Is there a clean and tidy way to do it without writing a massive amount of code? I'm saying this because i had a look at IanM's event handler feature and that seemed a little scary for little ol' me at this stage, lol
Chalkey
17
Years of Service
User Offline
Joined: 25th May 2007
Location:
Posted: 3rd Aug 2007 18:58
Hey

You are using the wrong operators. To compare two values in one if statement (or more than two) you would do some thing like this...



Have a look at this Wiki(!) page about C/C++ operators. http://en.wikipedia.org/wiki/Operators_in_C_and_C++

Cheers
Chalk
i cant believe its not fabio
18
Years of Service
User Offline
Joined: 10th Feb 2006
Location:
Posted: 3rd Aug 2007 19:41
mmh... now it works in a sense that the operator is correct, but i got the feeling that there is a command overlap somwhow.

What happens is that as i keep pressed the UpKey the character walks, then as i keep pressing the UpKey i also press the ShiftKey and expect the character to switch the animation loop to the one where it runs, but the animation does not get played, the character moves spatially as expected but the loop gets stuck in its first frame...
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 4th Aug 2007 21:43
Instead of using dbUpKey then try to find Scancodes for the keys.

Notice: The example is in LightEngine and VB.NET
cKeyboard is my keyboard class where I define keys
Player is the player object


With this code my player can go forward AND turn left or right at the same time.

Niels Henriksen
Working on a (MMO)RPG right now in DarkEngine
http://www.tigernet.dk - Send SMS to mobile online (will come in english soon)

Login to post a reply

Server time is: 2024-11-16 18:18:36
Your offset time is: 2024-11-16 18:18:36