I want create a snake game in Android using AndEngine. But in my game, the snake won't be controlled by the player. It'll just move in random directions.
I have a snake that can move in random directions. My problem is that I want real-time animation (i.e. the snake shouldn't just move after a delay).
I tried using register modifiers to move the snake, and that works. But the problem is that I have images for each snake's tail element.
If I had just rectangles, I would know how do this, but I'm using more advenced images.
When the snake changes direction, I should have an element connecting different directions (example: right and down).
Is there any algorithm for this? Alternatively, where I can find an open source project that explains this?
It's the same with rectangles. Ideally you wouldn't delete the images for the time of the animation.
Related
I have image sprites representing two polygons below. These polygons loosely represent the sprite area. What I want to do is use these polygons to detect the overlap (or collision) of sprites. However the overlap should be valid inside the green square. (this is a jigsaw puzzle game, what I am trying to implement is snapping of puzzle pieces when they are moved closer)
I tried Intersector.overlapConvexPolygons(adjacentPiece.polygon, currentPiece.polygon); however this one detects overlaps for entire polygon.
Any clever things I can do here to detect the overlap.
I think your approach might be over-complicating it. If you need your puzzle pieces to bump into each other, you can keep your physics boundaries, but if not, you can remove them entirely.
Either way, to detect if two pieces should snap, you can approximate each piece by a point roughly at the center of each of the piece's four basic sides. To test for pieces being close enough to snap together, you only need to measure the distance between the points on the sides of the two pieces and see if it's smaller than some threshold value you want to use.
If this is a typical puzzle game, you would only need to check this when the player releases a piece, so if it takes a while to brute-force cycle through all the potential matches, it won't really be noticeable because it isn't done while the player is dragging pieces.
If all your jigsaw pieces are a regular size you can simple use normal squares for each jigsaw piece. The square used to define the shape will be halfway between the solid part of the jigsaw piece and the extruded pieces.
From your image I have applied the squares to the pieces shown.
I want the sprite to walk towards the position of touch. To be more precise I want it to move like the main sumo in this game: https://youtu.be/Gj5CwgFUbI0?t=56s
The buttons provide pixel by pixel movement but I've to keep pressing them again and again to reach a point.
The Canvas event directly puts the sprite to the position touched.
This was answered by Ghica on Mit App Inventor forum and I just made a few edits. I used blank png 10*10 pixel as a Target Sprite.
.aia file
The logic should be like this, but i can't make it works, it's always freeze when the button touched.
My guess is because MIT App inventor doesn't support multi threading. Sorry that was as far as i can help.
I am working on an app that will compare histograms in hopes to match faces.
The app allows the user to take a photo, select a few key points in the image and then the app draws circles around those points. I then detect the circles using the OpenCV Hough Circle Transform functions. Up to this point the app works great.
What I need to implement now is one of two options:
Detect the circles and create separate histograms for the area inside of each circle.
Detect the circles and blackout the area(s) around the circles and create one histogram.
I'm leaning towards method 2, but I'm not sure how mask/color/paint around the area outside of the circles after they are detected. Any input would be appreciated. Thanks.
Instead of painting the area outside the circles in the original image, why not create a new image and copy the content of the circles to it?
Another point is that histograms are independent of translation. So, it does not matter if you copy the circles to the exact locations in the new image.
Do clarify if I did not answer your question, or if you have other questions now.
I am using LibGdx to develop a game. For Now I am not using scene2D. I am struck up in increasing the levels of the game as I do not have the scrolling screen.
I like to design a a scrolling screen as it is in many games which are level based (for ref, lets say Candy crush). Could you please point me a example on how to have such a scrolling screen to show a bigger area where I can show many levels.
Thanks is Advance !
Using the Scene2D function is not necessary for this and is more for GUI implementation and different screens. The Scroll pane really shines when creating reading content that does not fit your phone. I do advice to start learning Scene2D to create MenuScreens and UI though.
What Candy Crush "simply" does is having multiple backgrounds that are placed next to each other and tile seamlessly. They use buttons in the correct place for levels. By dragging a finger across the screen the camera will move in that direction. For the movement from one level to the next there is probably something like a spline in play.
It is important only to draw the background tiles and buttons that are actually visible on the screen if you have many. Since these have fixed positions and you know your camera area and position you can calculate what to draw and what not. Just drawing everything each frame is likely to slow down your fps.
You can do a search on:
Tilemaps, for you backgrounds but you probably want them in just one direction so a simple 1D array would suffice.
Dragging, to move your camera. Here I gave a basic explanations on how I do it.
Splines, are a bit tougher and you do not really need them. They could be used to animate or move something along a curve.
Thats all, expecting you know how to create something like a button (click a sprite).
I am completely new to android game programming. I really dont have any idea how can we create animated sprites. I have seen this guy using that amazing application RUBE to create a game character http://www.youtube.com/watch?v=bBIXpu-D_Zo can we do that stuff in android too ?
Even if we can how can we load such massing character to our andorid project. I accept i am noob at this but i have great interest in game development, please help me with detailed answer.
Thanks in advance
What you'll need is a sprite sheet. A series of images on the same bitmap laid out in a grid. For example you would have 8 different sprites of the same character, 1 standing still., 1 left foot forward, 1 right foot forward and jumping and again facing the opposite direction.
When you draw the sprite set the coordinates to be drawn and on button presses change the variables controlling the coordinates.
A good tutorial is here http://warriormill.com/2009/10/adroid-game-development-part-1-gameloop-sprites/
and a sprite sheet maker can be found here http://www.codeandweb.com/sprite-sheet-maker
Hope this helps!