Libgdx not regging taps when tapping fast - libgdx

I'm making a game where a guy needs to run faster when you tap faster, but
Gdx.input.isTouched()
Stops working when I tap on the screen very fast, then it just keeps on being false.
Any ideas?

Libgdx can have its input handled in two main ways.
One way is polling, as you have implemented it. This method is considered unreliable, as it only checks whether something is pressed or not at any time.
The other method is by using an input processor. Creating an input processor as described in this link allows you to handle rapid presses as soon as they occur.
Implementing an input processor should resolve problems with rapid tapping.

Related

Good way to draw Console UIs in Cosmos?

So I'm developing an OS using C# and Cosmos. It's called Memphis, and I want it to be entirely command-line for now (like DOS).
But, something that most command-line OSes I've seen (Arch, DOS, etc) all have something like a console library that lets you create simple UIs with buttons, menus, inputs, etc.
I've already tried to write my own, but it was completely futile. I can draw a window and text on-screen, but not much else (I did have a basic window manager that kind of worked but didn't, you press tab to switch between windows, and left/right to select inputs like buttons, textboxes, etc and it did accept keyboard input and I could see the windows updating, but nothing actually changed despite the code theoretically working)
So I'm looking for a way for me to draw UIs on the console for my OS, but it has to be ENTIRELY managed, and must ONLY use what's in System.Console. It also CANNOT contain events. This is because, Cosmos can only really work with code that's 100% managed, and System.Console is implemented almost fully in Cosmos, and events throw an 'OpCode Mkrefany not yet implemented' when Cosmos' IL2CPU assembler tries to convert the compiled c# code to x86 ASM.

OllyDBG, follow Call Function

I recently started learning reversing again, and I encountered a problem using my OllyDBG. When debugging an EXE which has buttons that every button does a different thing, I can't seem to find a way to follow a specific button's code.
For example: I have a KeygenMe with 3 buttons: "Login", "About", "Exit".
I want OllyDbg to follow what happens when I press the "Login" button.
How do I do that? I know it is possible as I've done it before.
You can follow a button by asking for olly to stop when the program returns from a funcion.
Do this:
Start debugging your KeygenMe.
Focus on ollydbg window and press Ctrol+F9
Focus on the KeygenMe and click on the button.
Olly will stop on the return of the button function.
Some times olly may stop a little bit far from where you want to go like in user32.dll, so you'll need to trace back your way.
you can do this using two tectiques(that i know):
(Use one after you landed on the return)
Use trace back:
Run your program normally and then hit trace over Ctrol+F11
Then go back using - (Minus Key from numeric keyboard)
or Use Breakpoints
Put breakpoints till you find from were this function is called
Using Right click on the code find the references for the struction that you find on the first step.
keep doint step 1 and 2 till you find your function
(i use both but some times the first one don't work)
The way described above I think is the general one,and it should work on the majority of cases. However, if you already know in which compiler the app was built, you can use a specific approach for it and eventually you can reach faster and more precise what you are looking for.
Supposing the worse case that your exe wasn't built with .NET and you can't decompile it easily. There are some tricks.
For instance Delphi/C++ builder apps make a table in the binary with public object event and addresses, it is extremely easy to decode it, in fact there are some Olly scripts to do that.
On the other hand, if it was made with Visual C using MFC or something like that you can easily reach it if you know how MFC is called.

AS3 Error #1502

AS3
Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
Is there a way to temporarily suppress this on a specific block of code?
I am creating a HUGE dynamic 3d array of objects, 1000x1000x1000 and need the build to actually finish the initializing.
Your best bet would be to try and refactor your code. Perhaps you can make use of this tutorial which deals with the exact problem you are having.
http://www.senocular.com/flash/tutorials/asyncoperations/
Increasing the timeout is one option, however I would also suggest considering an approach that would build your arrays over multiple frames, that is splitting the work up into separate jobs. As long as you give control back to the Flash Player every once in a while, you will not get this exception.
I'm not certain of the specifics of your problem, however you will need to find a way to parallelize or just simply segment your calculations. If your algorithm centers around one major loop, then consider creating a function that takes all of the arguments necessary to record the context of a single iteration. Then, create a simple control loop that will call this function and determine when to wait until the next frame and when not to. Leveraging AS3 closures can also help with this.
Look for the script execution time limit in the "Publish Settings" (Flash). If you're using Flex, maybe this one can be useful: http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_14.html (check default-script-limits, max-recursion-depth, max-execution-time). Oh! It seems there's apparently no way to make it behave in a different way on a specific piece of code (it is a global setting).
I do not approve the increse timeout option. Because for all this time your appllication is just hangs the whole Flash player. And normaly user thinks it is down, and forses it to quit.
check this one out: How to show the current progressBar value of process within a loop in flex-as3?
And then you can even show the progress which would be really more confident for you and for user.

ActionScript - Should Event Dispatching/Listening Be Avoided Where Possible?

recently, i ran into a problem where i needed to access the List object from the List's custom cell renderer class.
there were 2 options:
listen for and dispatch a custom event to communicate between the 2 classes.
reference the List from the cell renderer class with the parent property: List(parent.parent.parent)
while it's much easier to choose the second option, i feel that dispatching and listening for a custom event would result in code that's more inline with the design of AVM2, offers greater control for communication and, as it's expected AS3, should be less difficult to debug or maintain within new hands.
however, i also feel that using an event is more expensive, requires attention to resource management perhaps making it more difficult to debug and maintain and could be generally overkill.
is this simply a matter of needs or taste? should dispatching/listening for custom events be avoided if they can be?
Don't forget that you can't see the control flow of event listeners from single glances at the code.
While I'm not against event listeners completely, if you use them, you should try to use them in the most self-documenting and simple way possible. If you have clever stuff, like adding/removing event listeners, and it goes wrong, then it can be a nightmare to debug because you cannot see what dispatchEvent is going to do.
If owner gets you the right object, then I would just go with that, myself.
I would look at it from another angle. If the other option ends up creating more dependency between the two classes, I would definitely opt for event dispatching.
In that regard , I'm not sure why you think that an event driven application would be harder to debug & maintain. It would seem to be the opposite, but it would of course depends on how one implements the event dispatching in the application. But saying this and re-reading your question I realize you seem to contradict yourself! Of course , I tend to agree with the first statement.
...offers greater control for communication and, as it's expected AS3,
should be less difficult to debug or maintain...
...perhaps making it more difficult to debug and maintain and
could be generally overkill.

Game programming without a main loop

My professor gave my class an assignment today based on object oriented programming in Pygame. Basically he has said that the game that we are to create will be void of a main game loop. While I believe that it is possible to do this (and this question has stated that it is possible) I don't believe that this is required for adherence to the Object Oriented paradigm.
In a diagram that the professor gave, he showed the game initializing and as the objects were instantiated the control flow of the program would be distributed among the objects.
Basically I believe it would be possible to implement a game this way, but it would not be an ideal way nor is it required for Object Oriented adherence. Any thoughts?
EDIT: We are creating an asteroids clone, which I believe further complicates things due to the fact that it is a real time action game.
Turn based games or anything event driven would be the route to go. In other words, take desktop GUI apps. They'll just tick (wait) over until an event is fired. The same could be done for a simple game. Take Checkers for example. Looping each game cycle would be overkill. 90% of the time the game will be static. Using some form of events (the observer design pattern would be nice here) would provide a much better solution. You're using Pygame, so there may be support for this built in, through due to my limited use I cannot comment fully. Either way, the general principles are the same.
All in all it's a pretty rubbish assignment if you ask me. If it's to teach you event driven programming, a simple GUI application would be better. Even the simplest of games us a basic game loop, which can adhere to OO principles.
Hmm. In the general case, I think this idea is probably hokum. SDL (upon which PyGame is implemented), provides information to the program via an event queue, and consuming that queue requires some sort of repeatedly checking the queue for events, processing them, and waiting until the next event arrives.
There are some particular exceptions to this, though. You can poll the mouse and keyboard for their state without accessing the event queue. The problem with that is it still requires something like a loop, so that it happens over and over again until the game exits.
You could use pygame.time to wait on a timer instead of waiting on the event queue, and then pass control to the game objects which poll the mouse and keyboard as per above, but you are still 'looping', but bound by a timer instead of the event queue.
Instead of focusing on eliminating a main loop, how about instead think about using it in an object oriented way.
For instance, you could require a 'root' object, which actually has its own event loop, but instead of performing any action based on the incoming events, it calls a handler on several child objects. For instance when the root object recieves a pygame.event.MOUSEBUTTONDOWN event, it could search through it's children for a 'rect' attribute and determine if the event.pos attribute is inside that rect. if it is it can call a hypothetical onClick method on that child object.
I think it might qualify as event driven programming? Which can still be object oriented. You see this in Flash a lot.
There's a difference between a main loop in a main class. You can still have a game class initialize all of your objects, and then rely on inputs to move the game onward.
Kinda hard to say exactly without knowing the exact parameters of your assignment, the devil is in the details.
You might look at how python utilizes signals. A decent example I found is at: http://docs.python.org/library/signal.html