#151745 - MinxOfInsolence - Tue Mar 04, 2008 11:45 am
Hi All,
New to the forum, in the middle of an assignment to create a geometry wars clone and am stuck on a certain part.
Have to create an array of enemies, but most of them will be placed off screen. When I move to the part of the screen they are at, I need to convert from world to screen coordinates but i am not sure how.
Can anyone help with this??
#151748 - nanou - Tue Mar 04, 2008 2:16 pm
I think this is probably something you should figure out for yourself. If you want to program games you'll have to find solutions to novel problems every day, and if I understand what you're asking correctly, then being told the answer will waste an important learning experience for you. (To me the problem sounds simple with one complication.)
I hope this doesn't sound mean, I do like to help people when I can (and Eris help me if I sound elitist) but I think you're best served by working it out yourself. Plus, you said "assignment," which sounds like schoolwork... if so, you shouldn't even be asking for the answer.
PS. do you have any ideas for solving this problem? Even ones that don't quite work? If all else fails, try describing the problem in terms of what your code knows and what you want that to do. Then pose your question in terms what you're missing in order to solve the problem.
_________________
- nanou
#151749 - nczempin - Tue Mar 04, 2008 2:27 pm
nanou wrote: |
I think this is probably something you should figure out for yourself. If you want to program games you'll have to find solutions to novel problems every day, and if I understand what you're asking correctly, then being told the answer will waste an important learning experience for you. (To me the problem sounds simple with one complication.)
I hope this doesn't sound mean, I do like to help people when I can (and Eris help me if I sound elitist) but I think you're best served by working it out yourself. Plus, you said "assignment," which sounds like schoolwork... if so, you shouldn't even be asking for the answer.
PS. do you have any ideas for solving this problem? Even ones that don't quite work? If all else fails, try describing the problem in terms of what your code knows and what you want that to do. Then pose your question in terms what you're missing in order to solve the problem. |
Yep, the OP should read this and try again...
#151750 - MinxOfInsolence - Tue Mar 04, 2008 2:39 pm
Thanks guys but its not a school assignement and I've been at it for days now. I was hoping someone would be gracious enough to help me with this as I am at my wits end.
Hence the "please help" in the topic subject heading!
#151752 - poet - Tue Mar 04, 2008 3:32 pm
Visualize your problem. If you can't do it in your mind use pen and paper.
Draw your world, screen and some objects. Should be pretty easy to solve ...
#151753 - M3d10n - Tue Mar 04, 2008 3:40 pm
Geometry wars? This is 2D then, right? If so, it's very simple.
The first thing you need in a 2D game where your world is bigger than your screen is a camera. This "camera" is nothing more than a X and Y coordinates (maybe a W and H scale factors if you have zoom going on) which tells which part of the world will be drawn at the top left of the screen. The idea is that you only move the camera, and then everything scrolls accordingly.
To draw your game correctly based on the camera position, first all your objects' coordinates are to become "world" coordinates, independent of the camera and the screen scrolling. Then, before drawing each object you calculate its "screen" coordinates, which are relative to the camera position.
If you haven't figured out how to calculate these screen coordinates by now, I seriously advice you to use google and read some articles on coordinate systems and vectors, but here's the secret to speed things up: screenCoord = worldCoord - cameraPos
You don't need to store these screen coordinates for every object, just calculate them before rendering each object (that's not gonna slowdown your game either: 3D games need to something similar, but more complex, several thousand times per frame, for each vertex and they still run fine).
#151754 - nczempin - Tue Mar 04, 2008 3:50 pm
MinxOfInsolence wrote: |
Thanks guys but its not a school assignement and I've been at it for days now. I was hoping someone would be gracious enough to help me with this as I am at my wits end.
Hence the "please help" in the topic subject heading! |
Have you read what's in the link I posted? Apparently not...
Quote: |
Prune pointless queries
Resist the temptation to close your request for help with semantically-null questions like ?Can anyone help me?? or ?Is there an answer?? First: if you've written your problem description halfway competently, such tacked-on questions are at best superfluous. Second: because they are superfluous, hackers find them annoying ? and are likely to return logically impeccable but dismissive answers like ?Yes, you can be helped? and ?No, there is no help for you.?
In general, asking yes-or-no questions is a good thing to avoid unless you want a yes-or-no answer. |
You just said it's an "assignment", but not this:
Quote: |
Don't post homework questions
Hackers are good at spotting homework questions; most of us have done them ourselves. Those questions are for you to work out, so that you will learn from the experience. It is OK to ask for hints, but not for entire solutions.
If you suspect you have been passed a homework question, but can't solve it anyway, try asking in a user group forum or (as a last resort) in a ?user? list/forum of a project. While the hackers will spot it, some of the advanced users may at least give you a hint. |
Even if it were a homework question, it would motivate many people to give specific answers if you were to describe in a bit more detail what exactly it is that stymies you.
As it is, asking about World-to-Screen transformation is a pretty basic problem, that can be explained in many different ways depending on your background. Please explain which parts exactly you do understand and which you don't.
#151822 - silent_code - Wed Mar 05, 2008 4:26 pm
well, i don't know geometry wars, but i sure know how to get a world to screen projection done!
as the others have already said, post a more detailed (technically) version of your question. is it 2D / 3D? do you just need 2D coordinates, or do you also need a depth value (for "back projections" - don't know what that means? read on)? what platform is it for (pc / gba / nds)?
i can only tell you to try to solve this problem with the help if good old openGL and the internet - you'll sure find a ton of solutions in tutorials. but knowing how things work is always invaluable.
well, i guess you write a good post now!
ps: (an advise) make that statement about the assignment clear to everyone. then, they'll be willing to help you. even if they decide not to give you a full solution, it's help you need to *find* a solution, that you'll get!
#151824 - nczempin - Wed Mar 05, 2008 4:50 pm
silent_code wrote: |
well, i don't know geometry wars, but i sure know how to get a world to screen projection done!
as the others have already said, post a more detailed (technically) version of your question. is it 2D / 3D? do you just need 2D coordinates, or do you also need a depth value (for "back projections" - don't know what that means? read on)? what platform is it for (pc / gba / nds)?
i can only tell you to try to solve this problem with the help if good old openGL and the internet - you'll sure find a ton of solutions in tutorials. but knowing how things work is always invaluable.
well, i guess you write a good post now!
ps: (an advise) make that statement about the assignment clear to everyone. then, they'll be willing to help you. even if they decide not to give you a full solution, it's help you need to *find* a solution, that you'll get! |
Well, Geometry Wars clone means it's 2D, and probably not a depth value. Probably no rotation either, so all that's left is translation and scaling (possibly not even scaling, judging by the description--just off-screen enemies)...
I'd love to help out given a bit more showing of effort by the OP.
#151828 - silent_code - Wed Mar 05, 2008 6:05 pm
i was just suggesting things to let him know how that sounded to someone who *might* have the answer ("24", get it?) to his question, but wouldn't know *what* the question was (yeah, just like in that book... let's build a planetary computer which will compute the question to the answer, but don't forget to make regular backups!). well... ok, let's leave it like that. ;^)
obviously not knowing the game i might ask (no need to respond) if he couldn't have made a 3d version of it? ;^D probably not, judging from his posts (no personal offense intended!)
in the case of 2D, you're right, it's bloody simple and i guess he won't post any more because he's already got the answer... probably delivered to him with a "DOU!" :?D (i know that one very well!)
#151836 - nczempin - Wed Mar 05, 2008 8:27 pm
silent_code wrote: |
i was just suggesting things to let him know how that sounded to someone who *might* have the answer ("24", get it?) to his question, but wouldn't know *what* the question was (yeah, just like in that book... let's build a planetary computer which will compute the question to the answer, but don't forget to make regular backups!). well... ok, let's leave it like that. ;^)
obviously not knowing the game i might ask (no need to respond) if he couldn't have made a 3d version of it? ;^D probably not, judging from his posts (no personal offense intended!)
in the case of 2D, you're right, it's bloody simple and i guess he won't post any more because he's already got the answer... probably delivered to him with a "DOU!" :?D (i know that one very well!) |
24? There?s something backwards about that...
If he indeed get the answer he could have at least said thanks. Of course we already spent more effort just chatting about him than it would have taken to just deliver the answer to his doorstep...
And presumably if he asks this question in a DS coding forum he has an interest in DS coding, and he'll be back for more assignments...
BTW I have no idea why my statements always end in ellipses...
#151839 - silent_code - Wed Mar 05, 2008 9:13 pm
<OT>
(for those who don't know:) "the hitchhiker's guide to the galaxy" -> the supercomputer's ("deep thought") answer to the ultimate question was "42" (not "24", sorry - i guess you're right, it's *backwards*). ;^D
that was just a mental image for the situation we have here: you've got to have the correct question first.
"more assignments" hi, hi ;^D
he should know that he's still welcome, though. just ask the "right" questions (or at least give enough info, so we can help instead of ranting around!)
</OT>