How to change phone screen view relative to game character - java

I'm not looking for a tutorial or anything, I just want a better understanding of how the view on the phone screen changes with respect to a character within a larger area. I made a crude picture to help my lack of articulation.
How would you move where the phone is viewing, I don't even know how to word it, my mind can't grasp the concept.

Let me try to articulate your question by using an example:
Lets say you are developing Mario bros. Now the entire level (black box in your picture) is when the level starts till mario reaches the castle (entry to next level). The red box is whatever part of the level user can see on the screen. Now you want to know how to achieve this (right?).
Although I am not a game developer, but the simple logic that comes to mind is that you just have to move the level (background) image to left when the player moves right (actually player is at the same place) and if you want to generate a 2D depth effect then you'll have to use something known as parallax scrolling
Following this link might help you in developing such games

Related

LibGDX make the world move and the player not

I'm working on a simple game with libGDX and want to make the main character to be fixed in the center of the screen and the world move when I press a button. I was wondering how to do... I was thinking to add a physicsBody to the world that contains other bodies and apply impulses to it when the button is pressed, is this possible in libGDX? And if it is, can i apply other impulses or forces to the bodies contained in the world's physicsBody? I think this way would be the best for me if it is possible, because i have to work a lot with physics, but if you have other ideas tell me please
There's no need to think about applying forces to all the non-character objects, that's just going to get messy very quickly.
The simple solution is to move your camera so that it always looks at your character. So your game loop may look something like:-
Process input
Update physics, character and other entity positions.
Move camera to point at character's new position.
Render
This way, you can update your game world without having to think about the camera at all. Then, when it comes to rendering, you can position your camera and render your graphics without needing to know anything about the game physics. It keeps the physics and rendering relatively independent, and makes it much easier to change things in the future.
For example, you may later decide that you want the camera to follow your character for the most part, but then follow a baddy whilst it is their turn. This is now easy to do, you just specify the character / entity to look at in your game logic, and then position the camera to look at whatever target that is, before you render.

how to i animate an object in android?

Hi i'm looking for a way to animate these little icons i have for an app i'm making. basically i want 3 little icons to slide from the top of the portrait android screen to the bottom continuously and randomly. I have searched a lot so sorry if this is a repeat but i just cant quite find anything i can understand. So far i have Nothing except the images and xml set up. If this is already answered can someone please point me in the right direction. Is there a way to go about this in xml or must i use java? also would it be easier to use a framework such as libgdx with box2D?
you can use surfaceview and making your whole screen as a canvas whereas you need to control your objects' position every millisecond, another option is using the Animation in android, you can refer to this link it is sliding from left to right and vice versa

Android game development structure

I would like to develop a game on Android platform, I have about a year experience with Java and also used the OpenGL library in C++. I also programmed Minesweeper and Connect Four in Java. Basically, here's the type of game I want to create:
Pressing the screen would make your character go up in the screen and releasing it will make it go down. I know there are games like this already but it doesn't matter to me, it's my current goal.
The structure of both games I programmed was quite easy, it was only a GridLayout. This wouldn't fit in any defined layout. Then, I have absolutely no idea how to test a character/environment collision. I'm also wondering what would be the easiest/fastest way to draw the "collision" environment, I assume it would be with OpenGL but from what I know, it would still take a long time and wouldn't be that easy.
I've been trying to find a tutorial about this but obviously, I've been unsuccessful.
PS: I already know the basics to make an Android app so you shouldn't need to worry about that.
think about each segment of what you're trying to achieve individually.
First off, you could probably read up on libgdx: http://code.google.com/p/libgdx/
it's a great android game engine which will do alot for the work for you.
For the player, think of it as just incrementing the players y position by a few pixels if it's pressed down, else decrement it.
For the map, you'd probably need some sort of 2d polygon based collision for the upper and lower collideable environments, libgdx has a physics library built in but i'm not sure how the support it for polygon-based collision. And finally, just create the map and make it wider than your game screen, and just move the camera along as the player moves.

java 3D render distance

I recently started using java 3D for games development.
I am currently working on an assignment, a simple racing game to be very specific.
What you seeing on this screenshot is just a box, i have given road texture to it, and another box representing a car (which will be replaced by an external model later)
This is another screenshot from a different angle.
As you can see, I am not able to render the whole road, I have been looking to render the whole path from a long time, but somehow, the java3d engine does not want to render the whole road It stops rendering at some point.
What can I do to get over this, I want to render the whole distance, so, the whole road will be visible.
Help would be greatly appreciated. :)
I'm not seeing any screens either, but you're probably looking for View.setBackClipDistance(double distance), which sets the distance at which objects begin disappearing.

Text-Based Java Game

I need to make a text-based RPG game with java. The first part of the assignment is super simple. we just use vertical lines and underscores to make a little rectangle and then add symbols inside the rectangle as things move, act, die, etc.
I've never done this before, so I want to run my idea by you:
What do you think about doing something like angry birds but with flying moving targets? There would be a little "bird tank" at the bottom left of the screen that would shoot birds. Another question: I'm not entirely sure how I would create a gun that shoots at different angles in a text-based format. And how would it work with aiming and shooting and timing, and such?
Update:
I think I'm going to try out a tank game. But I'm confused about how to implemenent the angle of the turret.
I would put the tank in the bottom left corner, put I only have text symbols at my disposal. I don't see how its possible to let the user control the turret, and make it move up and down by small amounts (at least, not until we start using images/gui's.)
Any ideas?
First, in order to make your idea meet the criteria of an RPG, you would have to add a few components. Your gun would need to gain experience as you hit your targets, and would have to level up after enough time. It could gain better speed or accuracy. It could also earn upgrade points that you could spend on different birds to shoot. It would probably also be cool if your targets had hit points and you had to hit some of them multiple times to kill them. You could show the damage by changing the color of the text. These elements will give it more of an RPG feel so that you can meet the criteria of the assignment.
As for the mechanics of the game, you're going to have to write some sort of physics engine. It doesn't have to be very complicated, just enough to be able to calculate or modify a trajectory and determine if there was a collision. This engine would have some sort of a tick() method on it where it would advance the positions of the birds and targets and then you could call a getCollisions() method and handle each one. That's the simple way. The more complex way would involve giving the engine its own thread where it runs constantly, as fast as it can. Then, when there is a collision, it fires off an event to a listener, and you set up some sort of handler to apply the damage to the target, award points, etc.
I would recommend you model the world in finer resolution than your text console. Make the text console simply mark the birds and targets by rounding them to the nearest 80x25 console location, but internally use a much higher resolution. This will keep it looking more realistic, even in an environment with such a poor resolution.
For the controls of the game, I would recommend putting a target reticule on the screen. The user can move it around with their arrow keys to aim and press the space bar to shoot. They wouldn't hit the target because gravity should pull the bird downward, or perhaps because the bird is a special shot that splits into pieces. Regardless, they would learn how to lead their targets appropriately, and that would be the skill of the game.
It's a complicated project. Good luck!

Categories

Resources