• Create Account

# epicpunnum

Member Since 11 Oct 2012
Offline Last Active Mar 12 2015 07:17 PM

### Help finding error in base 62 converter

02 December 2014 - 04:48 PM

I've been working on an encryption system for a program, and as a means of getting size of the encrypted String down, I decided to allow the system to put numbers into any base - 62 being the max (values going 0-9,A-Z,a-z). I wrote this out fairly quickly, and it works for the most part, but *almost* every output value is off on the last character (even worse if not using base 62).

Some example cases:
• 30400066288418849 becomes 2FEQDJkH9F instead of 2FEQDJkH9E (a difference of 1)
• 21392905688514741 becomes 1Zyk6HmZO9 instead of 1Zyk6HmZO8 (a difference of 1)
• 22236810928128038 becomes 1dqNWdRcwg instead of 1dqNWdRcwi  (a difference of -2)
• 1407619700686911 becomes 6Rhvv3b0J, which oddly is right?

As of right now, my code is this:

```private static final String toBase( long number, byte radix ){
throw new IllegalArgumentException("Illegal value for radix. Cannot convert.");

String str = "";
boolean isNegative = false;

//Before we start, let's do a super quick check to see if nothing changes.
if (radix == 10 || number == 0 || number == 1)
return (number + "");

if (number < 0){
isNegative = true;
number *= -1;
}
while ( number > 0 ) {
char c;
//digit value to char conversion
if (times < 10)
c = (char) ('0' + times);
else if (times < 36)
c = (char) ('A' + (times - 10));
else
c = (char) ('a' + (times - 36));
str = c + str;

//Then we end our iteration by preparing for the next highest digit.
}
if ( isNegative )
str = '-' + str;
return str;
}
```
I'm sure it's just a small error somewhere, or a tiny oversight, but I've been looking at it on and off for 5 days and still can't see it. System.out.println()-ing each step hasn't been too informative either, as the math seems about right. The digit conversions are all correct too (6=6, 35=Z, 44=i, 61=z, etc).I've been using this site and this one as a means to test my results. Both have the same results, so I think I'm the wrong one here.

Any help is greatly appreciated! Cheers!

### How big do multiplane parallax layers need to be?

06 July 2013 - 10:26 PM

Hello everyone!

For my game, a 2D platformer, I decided to add parallaxing backgrounds to create more depth. For this approach, I created an object for each pane in the background and foreground, having the following traits:

• Movement factor (scale): The proportion to the Camera's position that it moves at (ie: 3/4 of the Camera's speed)
• Position (x,y): Pretty obvious. For example, x = scale * Camera.x;
• Layer Image (img): The image used for the plane object.

As far as rendering the image at the correct location, I have that taken care of. What I struggle with is how to determine the exact image size needed to line up with the room correctly. By that, I mean: given a room's dimensions, a camera's dimensions, and a movement factor, how can I calculate the dimensions of the image, so that when the Camera moves to the edge of a room, all the layers line up?

Currently, the best formula I could come up with for the image size is (|scale| * room_dimension) - (scale * camera_dimension), but it only works on a few cases (mostly with foreground layers)

As a side note, the scale variable is a float data type with the domain of (-Infinity,1]. Any layer with a value from 1.0 to 0.0 inclusive is considered a background layer. Any layer with a negative scale value is considered foreground.

Any help is greatly appreciated

### Adding content in a story-driven game

21 April 2013 - 10:46 PM

I am constructing a barebones engine for my game, and because of its structure, it it very easy to create and implement new features, even after the game has been finalized and published. The specifics of doing this isn't too hard, but what I'm struggling with is the best way to present it.

My game is a 2D puzzle/horror game that has a large focus on story. As such, there is a natural progression of mechanics and difficulty; it may start with a simple button and door, and more to remote control puzzles, and finally work with challenging momentum physics puzzles that require more reaction time. Therefore, there may be mechanics that are slowly introduced and fit into the story.

However, what do I do after the game is done? Currently, I plan on improving replay value of my game by offering later updates in the form of a sub-game I'm currently calling "The Tower." In it, the player is subjected to a supply of new maps at random and with each update, more maps will be added, turning it into a game of "how many can you solve/survive?"

But let's say that I end up introducing a mechanic that's entirely foreign to the main story game. After playing the story, the player may be familiar with traps, buttons, doors, toggle switches, spikes, spawners, teleporters, and enemies. But what if when I make an update to expand on what can be done ingame, I create a new game mechanic? For the sake of explanation, let's say it's a window, which can only be smashed with an object moving fast enough. The player would have no knowledge of this; it may even seem like scenery for some, and they may never make the connection that it's an important mechanic.

In the story it could have time to be introduced, but if this mechanic is introduced after the story has been finalized, then it would make no sense to go back and change the story. And because changing the story is out of the question, that would leave just simply slapping it into "The Tower" sub-game, where it would be randomly show up without explanation or exposition.

So what I'm asking is: In a game where the story has been finalized, but the potential to add more content exists, what are ways to properly introduce new mechanics without simply telling them every time? What are ways to add new mechanics and puzzles into a story-driven puzzle game?

### Trigonometric Lookup Table: Float vs. Double

19 February 2013 - 12:21 PM

For a game that I am designing, I have been designing a barebones 2D game framework that includes physics, boundng boxes, cameras, game states, etc. Naturally, because my game is largely physics based, I felt the necessity to design a lookup table for my trig functions.

Currently, this Trig class uses only integer values for angles, and three arrays for sine, cosine, and tangent (Each as a Double wrapper object so that values could pass by reference).

In an attempt to try and make my framework less memory intensive, I have been going through my code an using appropriately sized variables over simply ints and doubles. It occurred to me that instead of saving hundreds of doubles (at 64 bytes each), I could cut that in half by using floats (at 4 bytes each).

My question comes in multiple parts: In your experience, would this help a good amount in terms of memory management - especially for lower end computers/netbooks? Would the loss of precision from a double to a float be significant to the player? Could this potentially increase the number of trigonometry-based object at any given time?

### Falling action in games

10 January 2013 - 09:51 PM

Hello everyone,
I had a question regarding the story structure in games.
From what I have learned in my English classes, all stories follow a very general form of progression. In most cases, it's generally shown as a "mountain" or something of that nature to show the tension in the story. The five different parts to this are:

1. Beginning/Exposition
2. Rising Action
3. Climax
4. Falling Action
5. Ending/Denouement

In literary works, although sometimes deviated slightly, this is mostly adhered to, making the conclusions to the books satisfying.

However my question arises from game design as we know it. Games are always structured around a difficulty curve, to make the game less monotonous, provide a time to learn mechanics, and maintain a challenge - which in turn provides the player with intrinsic rewards. From what I've seen in story-based games, the design of a game is focused on this difficulty curve. In many cases, platformer, action, FPS, RPG, adventure, and horror games use something along the lines of a "final boss" and sometimes even a "final FINAL boss" to design a final challenge.

While this may feel fine and good to the player, who is provided with the thrill of victory, it somewhat limits the story. By adhering to a difficulty curve it seems almost impossible to have any Falling Action. Rather, games provide one monumental challenge and then end.

The only game I can actually recall that had some form of Falling Action was Earthbound, allowing you to explore Eagleland and actually see changes, while returning to a normal life.

What I want to know is if there are ways to maintain a solid story progression, rather than leaving the player cut short? Do you think this is a significant difference from other story-telling mediums? When should story-telling take from the game's challenge?

I'd love to hear what you have to say on the matter, and hear examples to boot.
-Cheers!

EDIT: Apologies if this is more of a Game Design question. I felt as if it would be a good idea to hear from writers themselves.

PARTNERS