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 / Dark gdk Questions

Author
Message
Vinnie G
15
Years of Service
User Offline
Joined: 7th Jan 2009
Location: around here somewhere
Posted: 7th Jan 2009 23:28
First of all hello everyone.

This is my first topic in this forum.
I'm starting now so i have googled a bit to find a awnser but i didnt so:
how he dont allow the sprite to move out of the screen,
in 2d games.

my ideia is create a game similar to ricochet.

Cumpz
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 8th Jan 2009 18:06
im not familiar with the 2d methods, but you use something like
Vinnie G
15
Years of Service
User Offline
Joined: 7th Jan 2009
Location: around here somewhere
Posted: 8th Jan 2009 20:46 Edited at: 8th Jan 2009 22:18
I have copy that to the while (loop GDK())
but when I builçd it , this errors showed:

1>main.cpp(39) : error C2065: 'SpriteX' : undeclared identifier

1>main.cpp(39) : error C2065: 'WindowWidth' : undeclared identifier

1>main.cpp(40) : error C2065: 'spritex' : undeclared identifier

1>main.cpp(40) : error C2065: 'windowwidth' : undeclared identifier

1>main.cpp(41) : error C2065: 'spritex' : undeclared identifier

1>main.cpp(42) : error C2065: 'spritex' : undeclared identifier

so if you can explain me i will be very grate.

by the way im using Dark Gdk with C++ Visual Express Edition 2008.

Cumpz
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 9th Jan 2009 00:58
This is gonna be a long one, I can tell

@Vinnie - that tidbit of code is just an example of how to make a sprite stay "stuck" in the screen's visible area. That is a "pseudo code" example - in other words - it's not meant to compile. It's meant to convey the basic idea of keeping a sprite in the screen visible region.

Now - I don't know this game richochet but I imagine you want something akin to pong... where something can bounce off the walls. You're going to have to goole this one - search this forum first using the searches at the bottom of each forum page... but I can tell you that you are hinting at 2D Physics... even in the most simple state you need math to calculate the tradjectory change when the "ball" or whatever "richochets" off the side of the screen.

Finding the angle is easy enough - but dependong on how "correct" you want to tradjectories to look - (e.g. NOT just 45 degree bounces) you need to gets some math working for you. There are things called 2D Vectors which are a pair of numbers, typically referred to as "X" and "Y". You need to get a handle on these - as you will likey need these sort of coordinates in any game you try - 3D just adds to the complexity.

I'd search for PONG DEMO and things like that so you can maybe examine other peoples code to get a handle on what it is your asking so you can start to figure things out

--Jason

CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 9th Jan 2009 10:47 Edited at: 9th Jan 2009 11:35
I have made a out-of-screen-detection function!


And then you can call it with for example to make a ball bounce:

Very simple bouncing example, trough... -_-
Vinnie G
15
Years of Service
User Offline
Joined: 7th Jan 2009
Location: around here somewhere
Posted: 9th Jan 2009 10:54 Edited at: 9th Jan 2009 15:24
I've done it thx to the code of jezza with a few modifications.

thx for all the ansewrs.

Cumpz
Vinnie G
15
Years of Service
User Offline
Joined: 7th Jan 2009
Location: around here somewhere
Posted: 9th Jan 2009 20:54
hello again can you give just an symple example how to make the ball bounce,beetwen 2 padlles?

Cumpz

Login to post a reply

Server time is: 2024-11-25 11:36:45
Your offset time is: 2024-11-25 11:36:45