How to implment walls in Maze game in Java GUI - java

I have an image with walls in it for my little maze game but currently, my player can move around freely meaning on top of the walls. If I want to restrict this free movement with walls, do I have to paint multiple rectangles one by one and align them properly so that they match the walls in my image, and if my player is hitting a certain wall, I would have to make a collision detection check? Or would I need to make a Wall class and create wall objects with methods which can check if they are in contact with the player, can restrict the movement? How would I go on about achieving this?

Related

Maze Game Rectangle Collision With Character

so I am creating a maze game and I have the image/sprite that is able to move. I also have Draw.FillRects's as the board of the maze. I was just wondering how I am able to set boundaries or even store all these rectangles as an array so I can further use helper.intersect or possibly a loop to see if it intersected with any of the rectangles.
Thanks

MUD programming - map with graphical background

I'm currently working on a MUD project. I'd like to figure out how to use a static background IMAGE as a map. (These maps are like graph paper. Squares represent rooms, and lines connect the squares to show cardinal direction exits.) There will be custom "hand-drawn" maps for each area in the game.
On my GUI, there will be a section of the frame dedicated to showing this static map. When a player MOVES (goes east, west, northwest, etc), a red DOT will be drawn over the current room the player is in.
This is similar to other MUD maps, except in most cases those maps are ASCII/text. I would really like to be able to use an image as the background, and only "draw" the red dot representing player location.
Also, the distance between rooms would not be uniform, so I cannot blindly just move the dot say 50 pixels left for a western movement.
How would I go about programming this? I imagine I will need to pre-define where the dot would be displayed for each room.
Any help in the right direction would be appreciated.

Moving the Camera Not the Background - Java

Currently in a top down game I am developing, I want the player to always be in the center of the screen.
To accomplish this, I am just moving the background down when I want the player to move up, and vice versa.
However, now that I am adding enemies and other objects into the game, I want to avoid the movement getting all wonky when the map moves behind them while they are trying to move also.
Is there any way I can move what the JFrame is viewing up, without changing the coordinates of the background image?
For a better explanation of what I am trying to accomplish, look at the drawing below.
Is what I am trying to accomplish too complicated? Is there an easier way to do this?

Is there a way to track a rectangle on a JPanel (Like 3rd person)?

I've made a few 2D games using JPanels and the Graphics draw methods. For the game I'm currently working on, I'd like to be able track the player as they walk, from an aerial view (sort of like the earlier Pokemon games, where as you move the camera tracks you), but without having to hard code it (make it that when I walk, the x and y values of every other feature including the background moves the opposite direction). Is there another way to do this or will I have to hard code it?
Use Graphics.translate(x,y) where x and y positions are the positions of your camera or player. This will translate the origin of the graphics context to the point x, y.

Java 2D- Actual Player Collision Detection | Ignore Transparency

So I'm creating a 2D game platform that works with Tiles. Currently it won't let the player go through the any tiles and works fine. Though rather then stopping the player at a solid tile. I would like to stop the player at an actual object. Pretend the triangle is in a tile.
Whats Happening:
What I want:
I would like the player to be able to walk through the tile until their is no more transparents. Basically walk on the triangle.
Player Class http://pastebin.com/SJrzSvVV
Tile Class http://pastebin.com/V3nqxh61]
TileMap Class http://pastebin.com/fuj8dR5K
You should check out the intersects() method provided by the Java2D API.
You can define the two sprites as shapes and adjust the coordinates when the two shapes intersect. I'm guessing you are splitting up a BufferedImage to create the animation frames.
You can draw a Rectangle or Ellipse frame around your sprites and check those for collisions. The frames do not have to be visible but making them visible helps when debugging.
Figured it out, essentially what I did was I was creating this game using tiles. I created something to scan a tile and find out where it's transparent, and allow players to go through it or not depending on whether the transparency is already inside something in the tile or not.

Categories