Need Some Help

Blitz3D Forums/Blitz3D Programming/Need Some Help

stayne(Posted 2007) [#1]
Hello all, back from the grave with a question.

If any of you have played Vega Strike, you'll know what I'm talking about. What I want to do is turn a spaceship (while in 3D space) according to the direction the mouse is moving. For instance, if I move the mouse to the upper right of the screen the ship should turn up and right. No rolling...just pitch and yaw. The further the mouse from the center of the screen, the faster the turn.

I hope that makes sense :). I'm trying to put together something for my son's class and I haven't coded in Blitz3D for a good while!

Any assistance is appreciated.


stayne(Posted 2007) [#2]
Finally sussed it out. Maybe someone has a more clever idea :).

;positions	
x#=MouseX()
y#=MouseY()
	
;half of screen dimensions needed
w=GraphicsWidth()/2
h=GraphicsHeight()/2

TurnEntity camera,-(y-h)/w*3,-(x-w)/w*3,0



stayne(Posted 2007) [#3]
How would I display text and such on a second camera?


stayne(Posted 2007) [#4]
Quick shot for you all.




Moraldi(Posted 2007) [#5]
About your first question:
There are two functions I think can help you: MouseXSpeed and MouseYSpeed. Take a look in B3D help to see how can use them
About your second question:
Is this a screen shot from your game?. If yes then you already know how to display text. Why you need a second camera? Can you be more specific?


stayne(Posted 2007) [#6]
Thanks Moraldi, yes that's the game I'm working on.

I was thinking of using a second camera as a viewport on the bottom right corner for viewing selected objects. I tried it but ran into some confusion with hiding each camera's skybox from the other. I decided against it since I don't really fancy doing multiple passes.


Moraldi(Posted 2007) [#7]
Create a second camera outside of the main skybox and place your selected object front the second camera.
I am not sure if this is what you want because my advice its very simple...


stayne(Posted 2007) [#8]
Anyone fancy tossing me a couple of hints before I dive into the enemy flight AI? I just need to get them moving from waypoint to waypoint for now. That I can handle. It's the appearance of realistically flying (banking, etc) that I'm going to have trouble with.


stayne(Posted 2007) [#9]
Yet another question. I want more play in the mouse control. I'm looking to have a small rectangular area (circular would be even better) in the center of the screen that is dead space and doesn't have any effect on turning the ship. Once again here's the current code I'm using for mouse steering.

;positions	
x#=MouseX()
y#=MouseY()
	
;half of screen dimensions needed
w=GraphicsWidth()/2
h=GraphicsHeight()/2

TurnEntity camera,-(y-h)/w*3,-(x-w)/w*3,0


Any ideas? It's taking longer than I though to brush off the Blitz3D cobwebs..


Stevie G(Posted 2007) [#10]
Something like this ...

const DeadSpaceRadius = 50

if  sqr( ( x- w )^2 + ( y-h )^2 ) > DeadSpaceRadius
  TurnEntityEtc...
Endif




stayne(Posted 2007) [#11]
a quick little video of an AI ship stooging around:

http://www.headpile.com/stuff/d1.wmv


Stevie G(Posted 2007) [#12]
Looks pretty good. Seems to be a bit tough to shoot anything as you demonstrate.


stayne(Posted 2007) [#13]
Thanks Stevie G, wasn't really aiming at anything. Just firing off a few rounds.


Moraldi(Posted 2007) [#14]
Hey!
That looks great! Tell us more about your project.
What's the story
Is gonna be a simple shooting game or a space trading fighting game?
Do you have a time plan?


stayne(Posted 2007) [#15]
Another video (please excuse the shabby cockpit and other programmer art). Made some optimizations, implemented a VERY rudimentary weapon system and a few other odds and ends.

http://www.headpile.com/stuff/d2.wmv

I'm shooting for a multiplayer deathmatch/teamplay/CTF type setting. I plan to implement items floating in space for pickup such as weapons, ammo, armor, regeneration, speed boost, invisibility, etc. Think Quake. Server browser also but that will take a bit. I've also been kicking around the idea of portals to fly into that will warp the player to a different location. No ship will be faster or more powerful than the other. Players will be able to skin their ships.

I suppose I will need to keep the players in a confined zone, probably by creating a pivot in the center and damaging their ship if they roam too far.

Of course I need to concentrate on the basics for now, but I figure I still need to lay out a design doc of sorts.


stayne(Posted 2007) [#16]
Yet another video. Having fun with homing missiles :).

http://www.headpile.com/stuff/d3.wmv


Moraldi(Posted 2007) [#17]
stayne:
I liked the videos and the futures you are thinking about.
I hope to finish and give us a good game.


stayne(Posted 2007) [#18]
Thanks Moraldi.


Subirenihil(Posted 2007) [#19]
Const DeadSpaceRadius = 50

If  Sqr( ( x- w )^2 + ( y-h )^2 ) > DeadSpaceRadius
  TurnEntityEtc...
Endif

Sqr() just slows things down (not that it really matters in this usage).

This does the exact same thing, just a wee bit faster.
const DeadSpaceRadius = 50

If  ( x- w )^2 + ( y-h )^2 > DeadSpaceRadius*DeadSpaceRadius
  TurnEntityEtc...
Endif



stayne(Posted 2007) [#20]
another vid.. working on the CTF stuff. as always, ignore the crappy visuals. the bot picks up both flags near the end, which is not supposed to happen of course. still much to do.

http://www.headpile.com/stuff/d4.wmv


stayne(Posted 2007) [#21]
Over the weekend I made a heroic attempt to stitch Blitzplay Pro 2.2 into my code. Let's just say I made a mess of things.

Lesson for the day: If you plan on including network play in your game start the network code EARLY. Also, unless you're 100% certain (mmmhmm) the code you're about to stitch in isn't going to break things, back up ALL of your .bb files.

Needless to say I've set myself back a few days. Time to started unweaving my tangled web.