Android Drawing Moving Lines - android

I am developing a game using Android Studio where I need the blocks to move from right to left. I have a file as an input and it contains a string list which would look something like this:
[(160,0;7,58), (160,0;7,59)..]
The elements in this list should be seen as coordinates, the 1st number of each pair (in this case 160,0) is the coordinate on the Y axis and the second number (in this case 7,58 and 7,59) is the coordinate on the X axis
The idea of this list is that the first number of every pair is the pitch heard at that ms, which is the second number. And the lines that come in from the right should arrive at the left corner at the time they were heard.
Lets say I someone said one word (with the same pitch for this example), the list would look something like this
[(160,0;5,50),(160,0;5,51),(160,0;5,52),(160,0;5,53),(160,0;5,54),(160,0;5,55),(160,0;5,56),(160,0;5,57),(160,0;5,58),(160,0;5,59),(160,0;6,00),(160,0;6,01),(160,0;6,02),(160,0;6,03)]
Now in this given list the 160,0 is the pitch of the sound and the second number is 5,50ms. Now the idea is that the lines/bars that come from the right side will reach the left side at that point. This whole list makes one word and should be displayed as one block/line that moves from right to left.
The blocks should come in and then disappear (like it is illustrated in the illustration), pretty much like rainfall or in tetris where the blocks fall down but instead of hitting the ground they disappear. In the illustration you can see one full block and the other one is just coming in from the right. The 1st long block that you see in the illustration should move to the left most screen and then gradually dissapear.
I drew a little illustration of how it should look like : https://imgur.com/a/3X1dV
Is the best approach to create one block, clone it and move it on or draw new lines with "draw" or can someone tell me how I should approach this.

Related

Detailed gestures predicted with simple horizontal lines

I have a collection of Greek letters in a gesture library and for some reason swiping straight left or right comes up with a pretty good score for mu and iota, neither of which represent horizontal lines. This breaks the idea of my app. I'm currently using a score of 25 or higher to test accuracy of drawing the letters.
Fixed by adding two gestures. One called "left" and one called "right" and they're shaped like horizontal lines. When predicting the closest gestures, it counts as a failure if left or right have the highest scores.
This prevents users from swiping left or right to draw a complex shape.

Pou connect game algorithm

Recently I played a simple game on android called Pou, and one of it's inside games was a connect the dots on the field game. Here is a screenshot to better explain the situation.
At the beginning of the game you are given n-pairs of dots and you have to connect the same colored ones. While doing this you need to fill the matrix field.
Generating such a field is not a problem, but how can I be sure that it is solvable?
My question would be how can I generate a field that has a solution?
Is this a graph problem? Or some kind of a connectivity problem?
Of course I can always produce a brute force solution, but I am looking for something better
Actually you can generate the matrix in such a way that you can be sure it is solvable.
The main idea is as follow. Let say that you need i pairs of dots and the matrix is n by n
Set i randomly chosen cells (start points) as heads and to each assign a different color.
At each iteration for each color move its head randomly (left, right, up, down) into an uncolored cell and color it with i-th color. (if there is no legal such moves do not consider this color any more -- that will be the end point)
When you are finished and there is no uncolored cells you created a legal coloring of the board.
If there are some uncolored cells -- it may be quite challenging but for sure doable to modify / extend the coloring you obtained to fill those regions with some color -- the easiest way would be to exclude those regions from the matrix altogether :-)
Some other very loose thoughts:
each region that consists of more than 2 uncolored cells can be made legal (or at least some part of it) by assigning two additional dots to it;
you can split your initial n by n matrix into smaller rectangular parts and assign to each part some number of dots (proportional to the area) and use the above method -- for sure there will be less uncolored cells when you merge those parts back (on the other hand the puzzle will be bit easier).
UPDATE
once still in phase of coloring, if the next move produces a single, isolated cell: chose a different move and if no such move exists stop the coloring process for this color.
if you want to have a predefined number of dots (or the number close to it), check not only for single isolated cell, but for whole isolated regions. [btw. mind the possibility of coloring a candidate for isolation region by extending its start point]
for relative small n you can try using above method(s) until you hit full-coloring (so generate, check if legal, if not: generate again)
UPDATE II
If you have time you can try generating colors once at a time, with some probability of stopping, that depends on the length / area of the coloring. So basically just choose a random uncolored position and execute the above method. It should be easier to implement.

Emulating physical buttons / lower level touchscreen control

One thing I find many Android games and emulators get wrong is when the user presses multiple (on-screen) buttons simultaneously. I'm wondering how one could fix that.
Imagine a game like Super Mario World. You have two buttons on the right side (simplified): Y is for running and B is for jumping. Typically, you hold Y most of the time with the tip of your thumb, and when you want to jump you lay down your thumb and press B, too.
Situations like this understandably confuse Android. Instead of detecting two presses, it just moves the one from the Y button down a bit.
What I'd need to fix this is one of the following:
Raw touch data as a bitmap (but probably too computationally expensive, and doesn't leave the touchscreen anyway)
The detected touch points in more detail, e.g. as best-fit ellipses or polygons
The ability to define touch regions. If a finger overlaps such a region a certain amount, the region fires.
(The points are from low- to high level, e.g. if I had the first I could emulate the other ones.)
Any ideas?

Animation sinusoid in android

I have a problem with moving animation. I want to create animation which start when I to a screen and she starts from touched place and go to end place like on this picture:
The end place is constant. How Can I do this sinusoid movement?
edit1: I want to click and when i click, show image and he goes this way to end place. I don't click and drag this picture. This picture must shows and goes to this place without my help. Only what I do is touch the screen. How I can do that?I have a problem with moving animation. I want to create animation which start when I to a screen and she starts from touched place and go to end place like on this picture:
The end place is constant. How Can I do this sinusoid movement?
edit1: I want to click and when i click, show image and he goes this way to end place. I don't click and drag this picture. This picture must shows and goes to this place without my help. Only what I do is touch the screen. How I can do that?
I wrote something like this that allows curved animation, you can see the full answer (and working code) here: Problem to achieve curved animation
It shouldn't be too difficult to either chain a number of those together, or modify the algorithm to use a cubic (or higher) function to produce multiple curves.
Only caveat is that because of the bezier curve, there is no guarantee the path will actually travel through the middle point you give it. If this is a problem again you could easily replace the bezier algorithm I use in the above example with something more suitable for your needs.
Check the sources of TranslationAnimation where the translation is done. Then build your function that maps the sinus function on the line from start to end. You could start with setting a horizontal line of with length dist(start,end) starting at (start), mapping sinus on it and then rotating it around your starting point.

Android graphics , dynamic view

I am looking for help/resource that will help me in bringing up a image as follows in android view.
Image looks like x-y axis graph, with sawtooth waves along x-axis, this is a static image developed using certain tool.
I need help to make a line move, parallel to y-axis (red in color) that waits at origin(0,0) and starts moving along x axis until the sawtooth wave ends.
3.If you imagine this as image, there is a wave on x axis and a red line that moves across wave, which is the noise generated in android mobile.
Concern: How to overlap a static image (wave+x-y axis) with a dynamic image (red line) and make it move as the code runs.
There is a timer that will generate the noise (mute/unmute microphone) and user gets to see it in screen when these interference occurs.
I thank you for spending time to read my post.
Please let me know if there are any redundant info , I will edit my question.
If you subclass view you can draw whatever you want in the onDraw(). You just need to use the provided Canvas.

Categories

Resources