quick 2d space demo

Advanced game related topics
User avatar
aszid
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 01, 2003 8:38 pm
Location: California, USA
Contact:

quick 2d space demo

Post by aszid »

well,
here's a little program i whipped up thanks to hypervox's game programming guide. As you can see it's quite a bit different than the original, and i'm planning on adding far more to this to make a real game out of it.

anyhow, there's not much to do right yet in this demo, just fly around in space, it's still quite rough around the edges, but i just started working on it today, so i think i'm off to a good start.

anyhow, let me know if you have any issues, or if you have any advice for me with this project ^^

http://www.aszid.com/fly.zip
--Aszid--

Making crazy people sane, starting tomorrow.
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Post by J. Baker »

Nice work! That's one fast ship. :D
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
DriakTravo
Enthusiast
Enthusiast
Posts: 346
Joined: Fri Oct 10, 2003 12:42 am
Location: Tampa,FL,USA
Contact:

Post by DriakTravo »

Cool, but I still get the transparent color (255,0,255). Have you made sure that the 3d sprite is like 16x16 or 32x32, 64x64, 128x128, etc? Also some wont work when you have a 32 bit color depth. Otherwise, nice work! :D

Also I notice you have the bitmap outside of the exe. If you want to include it, try this:

Code: Select all

InitSprite()
initsprite3d()
;etc

Openwindow()
Openscreen()
;etc

CatchSprite(1,?SpriteData,#PB_Sprite_Texture)
Createsprite3d(1,1)

Repeat
;GameStuff
forever

end

SpriteData: IncludeBinary "shipsprite.bmp"
User avatar
aszid
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 01, 2003 8:38 pm
Location: California, USA
Contact:

Post by aszid »

hmm.....

interesting... I do have the sprite at 64x64 pixels, and on both systems i have tested this on so far i have been running in 32bit color... I wonder if maybe this has to do with what video card is being used? anyhow, i'll look more into that.

as far as including the bmp in the exe, this was just a quick and dirty basic implimentation of my idea, and i will most definantly not just have bmp's sitting in the folder when i have progressed further.
--Aszid--

Making crazy people sane, starting tomorrow.
DriakTravo
Enthusiast
Enthusiast
Posts: 346
Joined: Fri Oct 10, 2003 12:42 am
Location: Tampa,FL,USA
Contact:

Post by DriakTravo »

Well I am using a Radeon9800pro video card and I get the transparent color. I find that on my machine the only way to fix it is to use a 16bit color depth when you openScreen() the game. :-/

Another thing, when I enter hyperspeed and rotate without accelerating, the hyperspeed direction stays the same.

And one more small thing: When I slow down from hyperspeed, when the ship speed is between 81-100, I cannot enter hyperspeed again or speed up unless I go below 81 again.
User avatar
aszid
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 01, 2003 8:38 pm
Location: California, USA
Contact:

Post by aszid »

hmmm.... well some of those things are desired responses.... for example, when you're in hyperspeed and change direction without accelerating it *should* continue in the same direction as before, just like in space.

also.. i originally intended for hyperspeed to be a set speed, so that you could not accel or decel while in hyperspace, but i had a bit of a bug (which i have since fixed), in my current version any attempt to accel or decel will drop you back to "normalspeed" I've also put a limitter on the hyperspeed control, so that a) you can only use it once per second, and b) so that you must be going exactly your maximum speed to enter hyperspeed (current max speed is 80)

I've actually added a few other cool things to the program since i put this up last night, including shields, and some minor bug fixes. I'm working on adding weapons to the ship today, and working out all of the bullet code.

one thing that i've been having trouble with is the effect of changing your angle without accelerating, then hitting the up arrow to accel. right now i have some pretty *dirty* code in there that checks the angle difference since the last time you accelerated, and makes it so that it *kinda* works, but it's easy to find the issues with it.... for example, if you went full speed in one direction, then changed your angle by roughly 180, then hit the down arrow, instead of decelerating, your velocity is instantly reversed.... I'm still tryin to get that all worked out, but any advice would be welcomed.

I think i'll have another updated version of this up tonight for people to check out. expect shields and weapons!
--Aszid--

Making crazy people sane, starting tomorrow.
User avatar
aszid
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 01, 2003 8:38 pm
Location: California, USA
Contact:

Post by aszid »

updated!!!

Well, i've done quite a bit more with this, it's still has issues that i'm aware of... but it's a work in progress.

anyhow, i've added 2 different types of shields, and you can now shoot!
only one weapon so far... but it was mainly just to get the basic structure down.

still no enemies yet... and no planets or anything else... i've still got to finish up the code for your ship before i complicate things further.

anyhow, same link as before (http://www.aszid.com/fly.zip)

all feedback is welcome ^^
--Aszid--

Making crazy people sane, starting tomorrow.
User avatar
aszid
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 01, 2003 8:38 pm
Location: California, USA
Contact:

Post by aszid »

OKAY!!!

I have made further progress with this project! here's a quick list for anyone interested:

- added more shield types, some animated, and built an easy way to add more with no coding necassary.

- adjusted shooting code, so that you can shoot much faster, and the bullets keep the momentum that the ship has (when you're moving, and you shoot sideways, the bullet keeps the ship's forward momentum)

- adjusted a few other timing issues with some of the other controls, which i had put a time limit on. i was previously using Date() (very stupid, yes i know >.<)

- added a cloaking effect, hit ] when playing to activate. This does not work with shields, if you turn it on when shields are up, they are turned off, and you cannot turn on shields when you are cloaked.

- added the framework for a "galactic map" it's still in very early stages, but i've got most of it figured out. so far, there is one planet, at what *should be* 0 ,0. this is off by a bit, and i'll clean it up tomorrow.


The zip file has grown quite a bit because i've added a lot of bmp files, and i haven't done any resource compression or anything yet. (it's about 270k now) the exe is still pretty small at 34k, and i'm only at about 450 lines of code so far (including comments and blank lines)

honestly, i'm shocked at how quickly i've been progressing, as i do have a full time job, and i really haven't spent a huge amount of time working on this.

LONG LIVE PUREBASIC!!!
--Aszid--

Making crazy people sane, starting tomorrow.
Blade
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Aug 06, 2003 2:49 pm
Location: Venice - Italy, Japan when possible.
Contact:

Post by Blade »

I like it! :-)
Would you use floats for coordinates? I imagine you are using integers, but the movement looks very strange ...

(if the ship is rotated i.e. at 10 degrees and you give a small thrust, the ship doesn't move in the right direction, just horizontal)
I already did similar games with Amiga, thrust me :)
User avatar
aszid
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 01, 2003 8:38 pm
Location: California, USA
Contact:

Post by aszid »

you're right, i have noticed similar things ^^;;

i am not currently using floats for the coords, but i will try that today and see if it works. I was considering having the movement be spread across multiple frames to fix the problem, so that say, in frame 1, the screen moves up 1 pixel, and in frame 2 the screen moves up 1 and left one... if you know what i'm sayin.

anyhoo, thinking about it, floats should probably do the same thing with alot less work. Thanks for the tip ^^


I've done just a bit more tweaking of it so far, no *major* changes yet, but i might have some major changes done today, if so i'll have another version up tonight.
--Aszid--

Making crazy people sane, starting tomorrow.
User avatar
aszid
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 01, 2003 8:38 pm
Location: California, USA
Contact:

Post by aszid »

wow!

i updated it to use floats for all of the coords and it looks and responds far better now!

thanks again for the pointer ^^
--Aszid--

Making crazy people sane, starting tomorrow.
User avatar
aszid
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 01, 2003 8:38 pm
Location: California, USA
Contact:

Post by aszid »

well, i've updated it again, same link once again...

this time i've made these changes:

- changed coords to floats, ship moves accurately now (thanks blade)
- added a scope for the ship, i will be modifying it, but it's a start.
- made the planet bigger, and fixed it's coords, mostly
- made max speed slower, as when i add other objects to space it really was too fast.
- enabled the game to use a joystick, let me know if this causes anyone problems please.
- fixed a major bug with my angle calculations ^^;
- added a notice when the ship collides with the planet, i used a circle collision detection for this, so it's not 100% accurate, but close enough.

i think that's about it, no huge changes but alot of bug-fixes. I'm planning on adding a asteriod field tomorrow, with the ability to blow them up. tryin to get another step closer to a real game ^^;

i'm planning on making a huge universe, with many stars, and planets that move around them... and have moons that move around them... etc... of course, i'm a ways off from that, but i'll keep postin, as long as anyone is interested ^^

as always, any input is appreciated



*EDIT*
added a 16bit fullscreen exe to the zip file, if the transparencies don't work in a window, please let me know if they work with the fullscreen exe.

^^
--Aszid--

Making crazy people sane, starting tomorrow.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Hum... New update just crashes... Both executables !
User avatar
aszid
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 01, 2003 8:38 pm
Location: California, USA
Contact:

Post by aszid »

D'OH!

i have uploaded what should be a fixed version. I disabled joystick support for the time being, because i didn't spend enough time working on it, so i'm 90% certain that was the problem.


anyhow, it *should* work now, let me know if you still have problems.
--Aszid--

Making crazy people sane, starting tomorrow.
TheBeck
User
User
Posts: 39
Joined: Mon May 12, 2003 6:04 am
Location: the far west
Contact:

Post by TheBeck »

This is really cool. I love 2d space games! I look forward to playing future versions.
Post Reply