Small but interesting "view" example

Post here your demos and examples with the source files.
Forum rules
Always post the games with a screenshot.
The file must have the ged and data files (complete game source)
Use the forum attachment to post the files.
It is always better to use the first post to put the game files

Small but interesting "view" example

Postby Nanorobot » Thu Sep 09, 2010 2:06 pm

I don't know exactly, maybe somebody already uploaded something like this.

But here I want to show you interesting example of navigating "view" actor in game. View will be always between player and cursor. I think it can be useful for some kinds of TDS games.

How it works? It is simple mathematics, let me explain. We need to find coordinates of actor, that locating right between player and cursor.
First, we find a coordinates of vector "player-cursor" = cursor.x-player.x ( the same for .y). Then we need to find a vector for point between player and cursor. = (cursor.x-player.x)/2. And then we need to find coordinates of that point = ((cursor.x-player.x)/2 + player.x)

If you can't understand what I mean, just download example and see!

I hope it would be useful for somebody.

I would be glad to see some comments!

Enjoy!
Attachments
navigation example.rar
(12.36 KiB) Downloaded 124 times
I'm not an English, so sorry for my mistakes.
---------------------------------------------------------
I just like to create!
User avatar
Nanorobot
 
Posts: 4
Joined: Wed Nov 19, 2008 2:45 pm
Location: Belarus
Score: 1 Give a positive score

Re: Small but interesting "view" example

Postby lcl » Thu Sep 09, 2010 3:01 pm

Nice job! :D
That's cool! :D
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Small but interesting "view" example

Postby DilloDude » Fri Sep 10, 2010 12:17 am

You could also just use
(cursor.x + player.x) / 2
or
(cursor.x + player.x) * .5
(using multiplication instead of division, as it's more efficient)
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Re: Small but interesting "view" example

Postby savvy » Fri Sep 10, 2010 3:02 pm

OMFG, this is exactly what i was gonna have to make for the game im doing currently :o
ty
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: Small but interesting "view" example

Postby Hblade » Fri Sep 10, 2010 7:00 pm

Amazing :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score


Return to Game Demos

Who is online

Users browsing this forum: No registered users and 1 guest