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.

2D All the way! / Stop sprite going off the screen...

Author
Message
Dark Flame
21
Years of Service
User Offline
Joined: 15th Feb 2005
Location: England
Posted: 3rd Jun 2005 23:06 Edited at: 3rd Jun 2005 23:06
I've decided to make a space invaders clone, I've got alot of experience in 3D so I thought I might try out some 2D..Anyway the problem is how do I stop my ship from going off the side of the screen...My code is below.

Thanks



Pricey
23
Years of Service
User Offline
Joined: 22nd Feb 2003
Location:
Posted: 4th Jun 2005 02:37
That is not 2D. You're using 3D objects.

:: 3Ghz Pentium 4 / Hyper Threading, 1024mb RAM, 160GB HDD, 256mb Radeon 9600XT Graphics ::

:: Current Project: Sea Bound ::
Dark Flame
21
Years of Service
User Offline
Joined: 15th Feb 2005
Location: England
Posted: 4th Jun 2005 08:40 Edited at: 4th Jun 2005 08:40
What should i change to make it 2D?

zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 4th Jun 2005 09:15
Something like this.



~zen

Dark Flame
21
Years of Service
User Offline
Joined: 15th Feb 2005
Location: England
Posted: 4th Jun 2005 21:11 Edited at: 4th Jun 2005 21:14
Thanks zenassem! But the ship still goes off off the screen and won't come back...

comando 300
22
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 5th Jun 2005 02:37
Try this:




[href]http://www.freewebs.com/comando_300/[/href]
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 5th Jun 2005 03:28
I coded it backwards
And added the bits that commando 300 mentioned

the reason being is because i set the inc & dec to go by 4, So we need to bring it back in range.




Then just change the value of MaxRight to coincide with how big your ship image is.

This will give you a start, but there are many things that go into 2D movement and animation. especially timing code, to keep everything smooth.

~zen

Dark Flame
21
Years of Service
User Offline
Joined: 15th Feb 2005
Location: England
Posted: 5th Jun 2005 04:35 Edited at: 5th Jun 2005 04:35
Thanks again zenassem and comando 300! I'm going to Work on shooting and some enemies.

Thanks

NanoBrain
21
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 15th Jun 2005 09:59
Dark Flame,

As an ender, and slightly off-topic, I would like to explain a short about 2D and 3D. The D stands for dimension(s). So, 2D means 2 dimensions, and 3D means 3 dimensions. 3D is drawn in, and able to be manipulated in 3 dimensions. Theses dimensions include the 3 axises of direction. One, up and down(y axis). Two, left and right(x axis). Three, fowards and backwards(z axis)(Note, that these axis are sometimes represented by different alpha characters in other programs).

In a 2D game, the objects can only go in two dimensions. Left-Right(x axis),Up-Down(y axis). You might already have this knowledge, but according to your quote "What should I change to make it 2D?", I figured I should throw in a simple explanation, just in case you didn't.


+NanoBrain+

Login to post a reply

Server time is: 2026-06-12 09:26:11
Your offset time is: 2026-06-12 09:26:11