Hi,
(still on the subject of my space shooter).
I have an idea to represent my movement patterns, wich seem fast, and flexible using scripting and bits manipulations.
But, I suck at bits manipulations, maybe some of you can help.
Here is the basic idea:
- The pattern script is a binary file.
- Each “instruction set” is a 64 bits word of 4 parts of 8 bits.
- The first 8 bits represent the “repeat” count (how many time the instruction must be repeated before going to the next one).
- The second 8 bits represent the instruction itself (SHOOT, MOVE, SHIELD, RETREAT, TARGET, etc…)
- The third and fourth 8 bits represent X, and Y respectively for a MOVE instruction, or any other parameters if needed by the instruction.
ex:
00000001 00000001 00000001 00000001
REPEAT 1 MOVE X=1 Y=1
00000001 00000001 00000000 00000001
REPEAT 1 MOVE X=0 Y=1
Would end up making my entitie move one step down/right and the one step down.
Questions:
How the hell do I do that in java? (and what about negative numbers)
(both creating the “step” and reading the step)
It would be even better if multiple instruction could be use of the same “line” (like MOVE & SHOOT) without creating a new instruction.
I would appreciated an example, or links to documentation around that.
Thanks,
Seb