Okay, so I am trying to make a game much like an old game called "Chip's Challenge".
Right now I have a square that I can control with the arrow keys but I'm not sure how to make a wall that cannot be passed through, could anyone help me?

Recommended Answers

All 14 Replies

It's called "collision detection".

commented: Very unhelpful +0

Thank you for your "helpful" and "informative" post helping me to resolve my issue. [/sarcasm]

It would be very helpful if you could at least give me an example or link me to a website with examples.

commented: Well, the next post contains your "useful" examples. Not necessarily in Java, but that shouldn't matter, the principle is the same. -2

Wow thank you for introducing me to google, my life has forever been changed now that i know the power that is, google.

If i were still trying google do you think i'd still be posting here? I came here for assistance so that i could hopefully have this explained to me in a manner a little easier to understand. I have a hard time fully retaining what i read on some of the hits google gives me and ive always found that the community here has a better way of explaining things, you however are completely unhelpful and i'd appreciate it if you no longer posted useless information.

Well then, let's see how much you have learned using Google. Without thinking of any specific language, what is collision detection and how might it be used in this situation? Where you have a moving object that you don't want to cross certain areas?

IOW, I have told you what it is you need to use to accomplish this feat, and even pointed you to resources to learn something about it, and you don't seem to want to do that. It seems to me as though you want "teh codez". Well, you are not going to get them here.

Designate coordinates that should not be crossed then use collision detection to determine when your "moving" object has reached them. The principle is simple, now start studying.

You still seem to be making this a very unpleasant place to ask for help.

All i am asking is where i should look that would help a beginner start to learn collision detection. You however are completely unhelpful in every sense of the word and i would greatly appreciate it if another member of this board could help me rather than this arrogant "moderator". I do believe moderators are supposed to be friendly and are supposed to help the community.. Hmm

I'm not sure how to make a wall that cannot be passed through, could anyone help me?

There are different ways to use collision detection, but a basic way, using rectangles, is to use the rectangles bounds and position on screen. And make a check as to whether any suitable values are overlapping/near the same point.

So,
1. get your "player" blocks x,y coords. Get its width and height.
2. get the walls x,y. Width and height(where needed)
3. You will need to find a way to use the players and walls width/height to calculate the correct distance from the walls x,y and the players x,y
4. if player > or < walls x or y , set speed or similar to be 0

commented: Helpful and informative +0

I dont have the code on hand right now (It's saved on my flash drive which i left at school) But where its at right now i can move a rectangle around the screen using the arrow keys. I will try to replicate a crude copy of the code and attempt what you said Akill, ill post my result

All of which the first hit on the google search would have told you (and much more) had you bothered to look. All I'm asking for is some visible effort on your part.

Masijade please, i dont want to waste my time reading anymore of your unhelpful posts, something like the simplified information Akill has provided has helped me a lot, thats all i was asking for, not some code, just some clarification and information. Please stop wasting both my time and yours. You are being arrogant and rude.

Akill, im still working on trying to get my code, the school was closed today so i wasnt able to get the copy i have saved there back yet. I am going to write a new program that works somewhat similar and try what you posted. Thank you.

You claimed to have searched already, but seemingly not properly, as you asked abut "boundaries" without ever mentioning anything that even came close to collision detection, so I gave you a term to search. You didn't want to so I did the search for you and provided you with a list of links, and you didn't like that either. And, as soon as someone here regurgitated the same principles tht were to be found in the first link you said "cool I'll try that", so the only thing I can assume is that you have neither the will, nor the wherewithal to do any research. Well, then, good luck as you'll never make it as a developer if you can't take a few words as a guide and do some research. That is at least 50% of a developers job.

Who said im here to be a developer? Im here to get a project done, now please if you arent going to post anything relevant or on topic then dont post, you're a moderator you should know that, obviously you're not doing that right.. ;)

In this regard I am here to help you learn, and part of that is doing research. The ability, but more importantly the willingness, to do research is a boon to any occupation and the opposite is a hindrance.

Edit: And FYI, everything I have posted here has been relevant to the topic. That you claim it isn't is part of the problem.

Seeings as how you are unwilling to post anything helpful to me i guess im done here, ill seek help elsewhere. That you for making this as unpleasant as possible and making me not want to be a part of this community.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.