How to show only part of map on screen - java

I'm developer of game Space STG II for Android phones... and I want to add to this game new option. To do this I need to know how to do movable screen. I want to do a battle like in Heroes Might & Magic, but in mobile phone screen is small... I don't know how developers show only a part on screen of all things on map. I want to make a small map in corner which show which part of map is shown on screen.
I can't find it :/ I spend 2 days and I found only 2d tile moving, but I need smooth moves. Please help. I will give activation codes for Space STG II for help.

This question is rather vague, and so in return I can't reply with more than a vague answer. Adding this new feature to your game is very specific to how you wrote your game to begin with. If you used bad coding habits, it's going to be very difficult. From what I gather, you are trying to add a mini-map in the corner like many games have. If your model of the game and view are intertwined, you're going to have issues doing this. If you used a design pattern like Model-View-Controller http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller it would be easier to add another "view" of your model and implement it as the minimap. Sorry for the vague answer, but I don't have much else to work with seeing as you have a specific question with not many details of how your game is written.

If you're writing OpenGL code, its extremely easy- just draw the scene and move the camera to look at whatever location you want. Scrolling means moving the camera and will be smooth. Note that a tile approach works fine with OpenGL
If you're using some other 2D API, it might not be that simple. You could try to look up algorithms yourself for how people implement scrolling in widgets (think- how do people make a listview?). You'll come up with something.
Edit: If you do accept this answer, I don't really want your activation codes. Thanks anyway.

Related

Android - Set Canvas to always be 1920x1080p?

Im developing a mobile game in Java on a canvas. But when I use different sized phones, the alignments are wrong and the hard coded offset values to correctly place buildings don't match with the new canvas proportions. Also, the UI elements are wrong size now and dont match the screenheight. Feeling kind of lost on how to best solve this issue.
I know that hard-coding the game to always be 1080x1920p will probably lead to black bars on some phones, something I'd also want to avoid if possible.
Canvas.scale did not do the trick, it only achieved crashes.
Anybody got experience in this? Thanks!

Android only allow entry through one side of rectangle

I am creating a game where the user can move certain objects into others (these are rectangles), however I only want to be able to enter the rectangles through one side, and it will be blocked by the rest.
I have no idea how to go about doing this, I have googled and found nothing that will help me understand what I need to do. Also, how would I go about doing this if the rectangle was at an angle, say 45 degree slope?
Any help appreciated.
Thanks
Tom
Tom, if you are new to Game world you need to search more about game engine for android.
Actually you need to search more about collision detection in android.
for more help try to read more about this game engine :
http://www.andengine.org/
there are lots of engines but you need to learn them.
Regards,

How does notch do animation in MiniCraft?

I looked through the source code of notch's 48 hour game Minicraft trying to find out how he does animation. By animation I mean like walking animations with different images. I looked through the code for about 30 minutes and I couldn't find anything to do with image animation.
Could someone please help me because I really want to know how he does it because it will definitely be helpful for me in the future.
Link to source:
https://s3.amazonaws.com/ld48/ld22/minicraft_source.zip
He is reading the resource image where he drew all the animation frames in a grid, he is cutting each frame and puts it in one bitmap array, resulting in an array of animation frames, and then according to the direction and type of animation he needs to do, he is just looping through the frames in the array and rendering the according frame on the canvas.
Not sure how Notch does it exactly, kind of an oddish question to paste us the entire source code and say "GO!"
A better approach is to look at how animation works in tutorials. There are many different methods to animating sprites, some more complex and work intensive than others.
I have been learning to program in XNA, which is a DirectX framework in C#, basically built to help game developers make games a bit more easily.
The XNA tutorial they provide has a section on animation their ship, you may find it useful.
http://create.msdn.com/en-US/education/tutorial/2dgame/animating_the_player
Good luck!

Animate a single figure

I can't understand how to animate a single figure in Java applet, while the context remains the same (for example rotate a polygon while other figures drawn remain the same).
Is there another solution besides repainting the object and the whole context? I am asking because it would be hard to have for example a number of figures that would need to be animated when clicked.
Could you please point me towards the topics I need to understand, as well maybe an example to see things more clearly?
The technology you want is sprites. There's a short intro video here and you can search the web for oodles of info about implementing them in Java.

Do I need to use OpenGL in my 2D Java sim game?

I have recently been developing a sim game in java, as many of my questions show, and it's come a long way! Graphically, it is somewhat lacking, and at current I'm using shapes for items, people, rooms etc.
I was looking at other similar projects, and noticed that one was using OpenGL. I have been reading CokeAndCode "space invaders 103 - refactoring and OpenGL", and I still don't know if it is something I need in my game or not.
Here is a video that I used for a previous question, but it still shows basically what I have so far (http://www.screenjelly.com/watch/Bd7d7pObyFo), although I have done a lot of refactoring and re coding over the last few weeks, but graphically, nothing has changed. As I understand it, I'm currently using java2D to do this.
I really don't know how I should continue graphically with this game. This is my first project I have done outside of learning for my own enjoyment, and so I'm still rather new to this.
Thanks in advance!
This could turn into a long subjective conversation quickly but I want to state the fact that you don't need openGL. Your application doesn't need to be the best looking one out there. Nethack still attracts people and between you and me : the graphics sucks.
Do you want to learn about 2D and 3D graphics and textures and so on ? Then try stuff... best way to learn. Then you can add this to your resume.
There are a lot of tutorial to do your first steps in OpenGL or some other graphic library. You can even try Qt Jambi. But once you start, you're in for a ride ;)
According to this, it's still largely possible to implement a working graphical game in Java2D with decent performance, as long as you make sure not to do a certain number of bad things.
It might help you to check and see how your approach is, compared to this.
I have no idea how far along Java has come with OpenGL support, so were I in your place I would probably just see how much refactoring of the Java2D code I could do, and figure out what to do from there.
Hope this helps, at least a bit.
One good side of using opengl (even for 2D graphics) is that you will get (if properly done) hardware graphics acceleration for your scenes.
Also, you can use orthogonal projection and keep one of the axis (Z) as zero to do your 2D graphics. It will be easy if you want to add a 3D effect (like lightning or something) if you use OpenGL.
However it all depends on how much you want to improve the graphics, since adding OpenGL might make things a little more complicated than plain Java2D.
How to continue graphically: use textures, more interesting animations (implement a simple physics engine and/or collision detection, that always looks nice).
When you go 3d (for example using opengl) you can add lighting effects to the equation, that usually does a lot to the aesthetics of the whole. For example if the moving circle was a sphere with a nice texture (marble or something), then you could make it really role over the board, and you could specify diffuse and specular reflection values to vary the lighting like for example here.
Camera movement can also beef up the graphics.

Categories