texts: LibGDX Scene2D.ui - Resizable composite widget

texts:
I have a custom widget, composed by a button and a text field:

public class MyWidget extends Table {

  private Button button;
  private TextField textField;
  private MyWidgetStyle style;

  public MyWidget(Skin skin, String styleString) {

    super(skin);
    this.style = skin.get(styleString, MyWidgetStyle.class);

    this.button = new Button(style.buttonStyle);
    this.textField = new TextField("", style.textFieldStyle);
    this.textField.setAlignment(Align.center);

    add(button);
    add(textField);
    pack();

    // doesn't seem to make a difference
    //setSize(getPrefWidth(), getPrefHeight());
  }

  public void draw(Batch batch, float parentAlpha) {
    super.draw(batch, parentAlpha);
  }

  static private class MyWidgetStyle {
    public Button.ButtonStyle buttonStyle;
    public TextField.TextFieldStyle textFieldStyle;

    public MyWidgetStyle(MyWidgetStyle style) {
      this.buttonStyle = style.buttonStyle;
      this.textFieldStyle = style.textFieldStyle;
    }
  }
}

Now when I create a widget and add it to a table, I don't seem to be able to set its size to less than its preferred one (eg, height), as follows:

MyWidget w = new MyWidget(skin, "default");
System.out.println(w.getPrefHeight()); // 35

...

Table table = new Table();
table.add(w).height(20);   // drawn at 35

If the value for height() is smaller than 35 (the preferred height), the widget is still drawn 35 units high.
Since the widget extends Table, it doesn't have a setPrefHeight() method and anyway, from what I've read, it shouldn't be necessary to explicitly set height on the widget, as setting the table cell height should be sufficient. Now my question is, do I have to implement some other method in MyWidget to have code like table.add(w).height(20); work as expected?


texts: Generating Weapon Damage Based on Item Level

texts:
I bring with me a question on loot generation from ARPGs.  In Diablo 3, items are generated for each level range, with damage range being defined manually.

I need help with an equation that generates weapons with damage scaling up based on level.

Level 1 - LowD - Lowest Damage

Level 80 - CapD - Cap Damage

I would like to generate weapons that scale linearly in damage based on item level. So item level is an important variable.

There are two additional factors: min damage and max damage.

Damage Range Example
Level X Sword: MinDmg - MaxDmg

MinDmg is a random number rolled by dice based on the linear scale with level.
MaxDmg likewise, is a random number rolled by dice based on the linear scale with level.

Level 1 Sword: 1-3

Level 10 Sword: 10-15

Level 10 Sword: 9-14

Level 80 Sword: 250-300

CapD is there to set the ceiling that the maximum range can reach up to.
Example is the max damage a level 80 sword can deal.


texts: Get water flow direction vector from water normal vector

texts:
Im stuck developing an important detail of my game water: Making it flow downwards!
Considering a typical 3D world in wich water tends to go towards gravity g=(0,-1,0) , and having the normal of the water surface n=(x,y,z), how can I calculate, based on that, the water flow direction vector?
As an example, consider this badly-done graph (In 2D, though)

Update: I'm considering a very simplified water surface (Just a plane: No ripples, no waves, no pressure, etc.). If any of those needed to be applied, the answer would depend on more factors than just the normal.


texts: How to move objects across a canvas with consistent speed on different screen resolutions?

texts:
I am making a rhythm game in Unity. I have been using Transform.Translate for moving images on a canvas as the music notes. However, I cannot consistently use this method on different screen widths. The notes move the same amount each frame.
I want to use interpolation for my music notes. I want to have the notes reach the center of the canvas at the same time despite the width of the screen. How can I write such a script?


texts:
I have written my own 3D engine and want to improve some of my render systems. Right now I've got a terrain system including the shaders). I can add 4 different textures which can be blended at any given place.

This leads to my first question:

What is the default way for using the blending data? A "blend map"
that stores the blending data or should I assign the blend data to each vertex? The second option makes rendering faster and I do not have to bind as many textures but the blending value is only being interpolated between the vertices. (Loss of information ?)

Furthermore, I've seen other games where they added some normal maps. It is not difficult for me to implement that but I've also seen that the normal effect only happens if the fragment has a specific range of the camera. Everything beyond the normal calculations does not happen.

What happens if I am outside of the (normal range), what texture is
being rendered?
This question comes up with the question no. 2: It can be seen that that
if (e.g mountains) are beeing rendered in the far the default "rock"
texture is not being used to which I would usually apply my normal map (because it is outside the range). Is there some kind of an overlay map for the whole terrain?

I would be very happy if someone could give me some advice on how to make my terrain look better :)

Greetings, Finn


texts: How to validate that certain fields are nonempty before the program starts?

texts:
I want to check that some fields are nonempty before any of the Start() functions run.

I tried to put checks in Awake() and Empty() and to quit Unity if they fail:

    #if UNITY_EDITOR
        Debug.Log("exit from editor");
        UnityEditor.EditorApplication.isPlaying = false;
    #else
        Debug.Log("exit from game");
        Application.Quit();
    #endif

It hits this code but it doesn't actually quit the game. I found that the Quit / isPlaying = false commands only work from Update


texts: I am create trying to create a Android game using Libgdx. I want to Create levels in game . So what i do. Which classes i need to use and how to create them explained. Plz help.Also i want to add buttons to game to move a car from left to right. plz tell me


texts:
How to do in HTML5 canvas Image animating?

I am have this code now: http://jsfiddle.net/WnjB6/1/

In here I am can add animations something like -> Animation.add('stand', [0, 1, 2, 3, 4, 5]);

But how to play this animation? My image drawing function is -> drawTile(canvasX, canvasY, tile, tileWidth, tileHeight);

Animation['stand']; return 0, 1, 2, 3, 4, 5

I am need something like when I am run Animation.play('stand') run animation from 'stand' array.

I am try to do this something like one day, but no have more idea how. :(

Thanks and sorry for my bad English language.


texts: OpenGL Reconstructing Position from Depth

texts:
I know this has been asked a lot of time before but none of those answers fixed my problem.
I try to implement deferred shading and to do so I need to reconstruct the world space position from the depth. (Having a position texture in the gbuffer would be a waste of data)

The calculation works fine for rotationing the camera (-> moving the mouse) but as soon as I move the camera (-> pressing wasd) they get weird.

GLSL:

vec4 screenSpacePosition = vec4(pass_Texture * 2.0 - 1.0, texture(gbuffer_texture[2],     pass_Texture).r, 1);
vec4 worldSpacePosition = invertedViewProjection  * screenSpacePosition;
vec3 finalPosition = worldSpacePosition.xyz / worldSpacePosition.w;

gbuffer_texture[2] is the depth attachment of OpenGL.
invertedViewProjection is the matrix I used to render the scene inverted on the CPU.


texts: How to keep the state of all games in the server?

texts:
i have a problem implementing a turn-based game server in java.

What i want is a way or a technic that let the server keep all the games state that are created in order to the client recover at the same state when an disconnection occurs.

Until now i have developed the server-client programmes and they work fine, but i didn't know that TCP can't recover over some situations of connection lose. So i get so many "connection timed out" errors, and my programmes don't have a reconnect and recover technic. Now i need to think a way the server keeps some info of all the games.

My (for now) solution is to have a class that all threads have a reference to, inside the class we have many ArrayLists to store every info we need so threads can access and handle them.

For Example:

Game-123 has the score 100 so an ArrayList scoreOfGame[123]=100

Game-3 PlayerB name is stored at ArrayList PlayersB_Names[3]=name.

If there is a better way to keep track of all game states seperately on the server, i would appreciate it!!!!


texts:
I'm working on two RPG battle mechanic ideas. I haven't chosen a game engine yet. Before starting to write code, how should I plan their details?

Should I draw and write on paper? Should I write a specification document?
What game mechanic planning processes have others used?


texts: How to create rounded TV edges effect in Unity?

texts:
Is there a way to get rounded TV edges like these:

I want rounded egdes and the distortion effect, but I can't find a way to do this. I am using Unity 2017.


texts:
For my HND I've got to re-create Frogger, and everything was going swell until I tried adding some collision detection and sound. Whenever my player intersects a vehicle, the sound file just starts playing with every game update instead of just once.

Here is my code from the update method:

            if (vehicles[count].bbox.Intersects(playerSprites[lives].bbox))
                playerSprites[lives].isDead = true;
        }

        if (playerSprites[lives].isDead)
        {
            deathSound.Play();
        }

The sound is declared as a SoundEffect, loaded as a SoundEffect, and the content processor is set to Sound Effect, and as far as I can tell, Sound Effects in XNA are only meant to be played once.
What am I doing wrong??


texts: Unity: Render only select objects but show previously rendered objects

texts:
I am making an RTS game which is having performance issues.

Is it possible to render the ground and units separately so I can only render the ground when the camera moves but keep the result displaying the units over the top?

I'm not sure what details to include but:

*The camera is fixed angle and orthographic

*The profiler says drawing takes up about 50% of CPU when units are moving.

*All the logic is done by a c# script outside of monoDevelopment but called through a gameobject each frame, (takes 2% of cpu in tests).

*Units are put in place using the "transform.position" command each frame.

*Units and tiles are instantiated and destroyed when the Camera passes them.

*The game is using rigged .3ds models for the units.

*The units have disabled rigidbodies.

*Each tile in the game is a separate sprite.

*The performance drops with ~100 low poly units without animation or ~20 higher poly units with animation.


texts: How long will a ball, say a billiard ball, stop rolling on a flat surface for a given coefficient of friction? What is the formula for the ball's decreasing velocity?


texts: Environment collision in a pseudo-3d 2d space

texts:
The game is a 2D brawler with depth movement in the vein of Golden Axe, Final Fight, Castle Crashers etc. Characters and environment are all 2d sprites as well. I've had no real issue setting up collision between characters to take the depth into account either.

However, it's just not a proper brawler without higher ground to jump to and pits to throw the enemy into, and that is where I run into a bit of an issue with how best to implement it.

I considered making the collision boxes for the level in the 3D space and having the sprites just translate the z movement of their game object into y movement of the visual component, but I don't particularly like that approach because it feels difficult to work with for doing the level design of matching 3D colliders to a drawn backdrop and placing objects in there.

Any suggestions for a design that is the 2D first, so to speak? Ideally being able to "paint" height levels and pits in the 2D design wise. If it matters, I'm working in unity with a primarily 2d space (though involving the third dimension here will be necessary), but I think the base design problem would be fairly engine/language agnostic.


texts: Unity animation tool doesn't save changes

texts:
I'm trying to create an animation inside Unity using the animator tool, however the record tool isn't recording my changes and I'm struggling to get this to create animations.

I have created an example here:
https://i.gyazo.com/91f88b3531b4fb3ffd4100d40f06bdcf.mp4

I have tried recreating the animation file, but no matter what I do it refuses to record the element?

Any information would be appreciated, as it appears unity may be bugged.

When applying an update between tweened keypoints the fields for X Y Z are red and do not apply changes


texts: Shooting the bullet out of the gun instead of the camera, yet keeping it accurate with respect to the reticle

texts:
I'm working on a first person game, and I've ran into a problem. In my game, there's the player's gun being rendered, as well as a reticle in the center of the screen - like this:

First, Let's imagine there was no gun model being rendered. Then firing the bullet is easy - you just spawn the bullet exactly where the player's "eyes" are, and then use trig to calculate the velocity based on whatever direction the player is looking.

But now, when we add the gun model... we can't just spawn the bullet where the players eyes are, we have to spawn it at the tip of the gun (right?). So you do that, but then... how do you move the bullet in a way that it will hit wherever the reticle was pointing?

Keep in mind that the bullet in my game (it's actually a rocket, in this case) will be moving slow enough that its movement can be seen, so some workaround that would usually work if the bullet is too fast to be observed will not work. For example, if you didn't spawn it so it looks like it's coming out of the tip of the gun, the player would definitely notice that.


texts: Approach in implementing the web browser game

texts:
Im Phil and try to figoure out the best approach for my app.
I was searching Stack for my question but I didnt find a completely answer.
Assumptions:

It will be multiple user who can see in real time their vehicles(locations,state, fuel), places(state, is it planted, is it mowed) etc.
Action taken by players - e.g. User click build/drive and have to wait for example 45min. I want to display to user time to end of action.
should action be registered in queue system ? ( RabbitMQ or something like this,generally a message queuing system)
After this time the object of user should change - User get coins or the vehicle change his place from X to Y
Remove this action from queue and store information about ended action in DB

Is my approach correct? Could I ask for ways to implement this? Or should I go in a completely different direction? I will be grateful for all the advice!

EDIT:
I found different solution: Store action in DB to build / drive and save the current timestamp and time when action is finished. Now i should have bacgrond process which will be looking into this DB and change state when the action is finished (add coins to player X e.g.) In the same time when user clik the request to server is send. In response got the time when te action start and finish. Javascript will be drawing to user the progres bar (calculated from current timestamp and from db) What in situation when user not send another request (not rerfresh site)? The script should check if action in finished (current timestamp > timestamp from db ) and then should automatically refresh user site. Is that correct?
Second aproach is simpler to implement IMO.


texts:
Is there any way to enable a temporary clipping mask in XNA while using a SpriteBatch? I'm drawing a bunch of Texture2D objects and Sprites in a given rectangle, and I want to make sure that said objects aren't drawn outside of that rectangle. If it's of any help, I'm already drawing my content within a Viewport, I'm not sure if I can draw, for instance, in another Viewport within that Viewport.

Illustrative image of what I'm trying to accomplish:


texts: Keep platformer jump height consistent with different frame rates

texts:
I want to achieve a platformer jump similar to that of Super Mario Bros. (keep pressed the jump button to jump higher) and I want it to be frame rate independent.
At 30 FPS it works as I want. However, I noticed that, if frame rate is lower (e.g. 10 FPS) the jump height is much lower.

The following is the pseudo-code I am using on my character. What am I doing wrong? Note: I'm considering the Y-axis to grow downwards, so a negative vertical speed means the character is moving upwards.

jump_force = 4000;
jump_max_speed = 800;
gravity = 2000;

yspeed = 0; // vertical speed (negative is upwards)
is_jumping = false;

update() { // called every frame
    dy = 0; // delta y-position for this frame

    if (yspeed != 0 && is_grounded()) {
        yspeed = 0;
    }

    if (jump_button_pressed() && is_grounded())
        is_jumping = true;
    else if (is_jumping && !jump_button_pressed())
        is_jumping = false;

    if (is_jumping) {
        yspeed -= jump_force * dt(); // dt() is delta time, i.e. time elapsed since last frame
        // cap vertical speed to limit jump height
        if (yspeed < -jump_max_speed) {
            is_jumping = false;
            yspeed = -jump_max_speed;
        }
    }
    else if (!is_grounded()) {
        // apply gravity only when the character is not jumping
        yspeed += gravity * dt();
    }

    dy = yspeed * dt();

    // if character would fall inside terrain, place it just above it
    if (dy > 0 && check_for_ground(x, y + dy)) {
        y = ground.y;
        yspeed = 0;
    }
    else
        y += dy;
}


texts: Unreal Engine Visual Studio 2019 C++ - Could not open source file CoreMinimal.h

texts:
I'm trying to follow a YouTube tutorial and I've ran into this (Severity    Code    Description Project File    Line    Suppression State
Error (active)  E1696   cannot open source file "CoreMinimal.h" Network2    E:\Unreal Projects\Network2\Source\Network2\MyClass.h   5   ) and a lot more errors, so if anybody has more experience than me with C++ please help me out.


texts: When I pause my game scene in unity editor by keyboard ctrl+shift+P，‘Assertion failed ...’ appears in console window

texts:
I am using Unity 2017.2.0f3. When I pause my game scene by use mouse click on pause button & play it frame by frame, it works OK. Instead, pause by use ctrl+shift+P keys down, an error will play once in console window at the time I press frame by frame button.

Assertion failed: Assertion failed on expression: '!dest.m_MultiFrameGUIState.m_NamedKeyControlList'
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

This would happens even in the new created empty scene!

Any help will be appreciated!


texts: Combining a pure ECS with a FSM scheduling system

texts:
Currently I am evaluating how to refactor my core game logic since I tried to design most of it in pure ECS but isn't really completely feasible the way I intended it.
My game at its core is a turn-based roguelike with multiple (implicit) phases during a turn:

Player Action Phase: Movement, Attack or Item Usage

If the chosen action was Attack or Item Usage, handle it right away
Otherwise, queue a Movement intent

Movement Phase: All units that decided to move will move simultaneously
Attack Phase: All enemy units that haven't moved will attack one-by-one
End Phase: Resolve status effects

These phases have been difficult to design with ECS. Certain systems have checks whether the should run right now with a bunch of tag components. Examples include:

The BehaviorSystem updates enemy entities, that are currently thinking (applied after any player actions have been resolved), but have neither finished their turn yet and are not suppressed by anything (usually used to await animations).
The AttackerSelectionSystem that only runs when no movement or attack animation is currently playing and then only picks enemies that still have to attack, sorts them by initiative and tags the next enemy to start his attack during the next frame.

Eventually my current architecture won't scale well with more and more systems to come, especially with different kinds of game states such as game elements that are UI only, in-town/hub maps where I don't need any of these combat/turn-based elements and finally the instance/dungeon areas where I will need them.

My idea is now to include a FSM in my Game class decoupled from the ECS itself to handle my current approach to invoke systems:
auto Game::Implementation::updateSystems(const sf::Time DeltaTime) -> void {
  updatePlayerControllers(Registry, InputManager, Tilemap);
  updateBehaviors(Registry, Tilemap);
  updateMovementAnimations(Registry, DeltaTime);
  updateAttackerSelection(Registry);
  updateAttackAnimations(Registry, DeltaTime);
  updateDamageEvents(Registry, ContentManager);
  updateFloatingCombatTextAnimations(Registry, DeltaTime);
  updateEndOfTurn(Registry);
  updateLocalToWorldTransforms(Registry);
  updateSpriteRendererTransforms(Registry);
  updateEntityRemovals(Registry);
}

Now I am evaluating how to implement this in a clean way. I fear with too many states I might end up with spaghetti scheduling using weird if/switch constructs. Alternatively I could add a check at the beginning of each system whether the current state of the FSM/game allows them to even run.
Finally a most sophisticated approach would most likely be a dependency graph with conditions that will schedule the systems to run each frame.
Are there any common patterns and approaches to handle this scheduling based on game/turn state?


texts: How should I implement side-scrolling level design?

texts:
I'm working on a college project using the educational Java framework Greenfoot, and as stated above we're making an r-type clone.

I've been looking at using an array of strings to populate the levels. The array contains 60 strings, filling the Y axis, each element in the array represents a y co-ordinate += 10. I use "0" to represent empty space, "1" to represent a block of terrain.

Then I use a for loop and charAt() method to create a new array representing each column along the X axis, and populate the screen this way.

I thought I was being clever by making a "block" class that checked to see if it was connected to any other blocks and adjust it's image accordingly to make the terrain look as if it's a single block/shape. However, this is now slowing down the game to a crawl as there are so many objects in it.

I've tried to add the columns as the game is scrolling and removing them once they leave the screen, but I end up with gaps in the terrain.

How are levels in these types of game normally implemented?
Would I be better creating a few big objects to make the terrain and build the whole level from start to finish?

Is there some method I've completely missed?

Here is a screen shot of how it looks at the minute, each block is 22 x 10 pixels.


texts: Point rotation around point, accuracy question

texts:
I study OpenGL ES 2.0. But I think it's more a C++ question rather then an OpenGL one.

I am stuck with the following rotation question: It is known, that rotation transformation can be applied using these equations (for simplicity suppose we rotating around (0, 0)):

x'=x*cos(theta)-y*sin(theta)
y'=x*sin(theta)+y*cos(theta)

But it seems that when I perform this rotation operation several times, the accuracy problem occures. I guess that the core of this problem is in uncertain results of cos() function and floating point limitations. As a result I see that my rotating object is getting smaller and smaller and smaller. By the way I am using C++.

1.) What do you think: Is this issue really connected to the accuracy problem?

2.) If so, how can I handle this?

Thanks.


texts: How do I communicate with an IronPython component in a C#/XNA game?

texts:
My XNA game is component-oriented, and has various components for position, physics representation, rendering, etc, all of which extend a base Component class. The player and enemies also have controllers which are currently defined in C#. I'd like to turn them into Python scripts via IronPython (a .NET implementation of Python). My problem is that I'm not sure how to interact with those scripts.

The examples in Embedding IronPython in a C# Application suggest I'd have to create something like a Script component which compiles a Python script and calls the controller's Update method via Python - essentially, it'd be a wrapper class for C# to interface with Python.

I feel that I'm missing something in my research. There must be a way to load up a script, instantiate a Python object (either in the Python script or in C#) and then then have a direct reference to that Python object in my C# code.

Is there a way to work with an IronPython object directly, or is a wrapper required?


texts: Telling my shader when to use which Texture

texts:
So I've just managed to get Texturing via GLSL shaders to work and i can pass a sampler2d textureHandler + my uv coordinates into my shader to specify the texture to be displayed on my Tiles.

Now im Wondering how I could define which tile should get which Texture cause right now I can only put 1 single texture on ALL tiles I have...

My vertex shader:

in vec3 position;
in vec2 vertexUV;

uniform mat4 orthoMatrix;

out vec2 UV;

void main()
{
    gl_Position = orthoMatrix * vec4(position, 1.0);
    UV = vertexUV;
}

my fragment shader:

in vec2 UV;

out vec4 outColor;

uniform sampler2D myTextureSampler1;

void main()
{
    outColor = texture2D(myTextureSampler1, UV);
}

My Texture Loading right now looks like this: http://puu.sh/62MhS.png


texts:
Tennis courts are real dimensions and game is 3D

Ball has position (x,y,z), speed(vx,vy,vz) and acceleration (ax,ay,az)

Game has 30 fps and on each update (1/30sec) it has these properties

vx +=ax;
vy +=ay;
vz +=az;

ball.x += vx;
ball.y += vy;
ball.z += vz;

function hitBall(destinationx, destinationy=0, destinationz) {
    // calculate vx, vy, vz, so ball imapcts  the point (destinationX, 0, destinationZ)
    // destinationY = 0 = bounce on floor
    vx = ....
    vy = ....
    vz = ....
// I guess this problem has infinite solution, so we must intersect with 1 point
// intersection line is (x,1,12)
// 12 is middle of the tennis court and 1 is 1 metter above the ground.
// ball passes there 1 meter above the ground.

}

Any clue on how to resolve that math problem ?

regards

Google doc :
https://docs.google.com/presentation/d/1EiUYpalDXlJUgjg8aIxLiWENgZJW7fnH4bGHsj1jb9I/edit?usp=sharing


texts:
When I select the Camera object, I see the border-lines, the near clipping plane and the camera preview. I would like to see all of these things when I select another game object.

In other words, I would like to still see the lines from the position and rotation of the main camera, but while having another object.

I know it somehow works with a custom inspector, I also found some solutions which seemed close ("how to create an editor screenview" and "show camera preview"), but I couldn't get them to work.

How do I show the position and rotation lines of the camera, while having other game objects selected?


texts: JMonkeyEngine display a spatial in a Nifty GUI interface

texts:
I want to display a spatial (or the rendering of a spatial/scene) in my HUD interface. I'm really not sure how to go with this. I have search the documentation, but all the queries I search yields no result, and all I could find about images is that one can specify one with the setBackgroundImage method in the builder and setImage from the ImageRenderer class. The latter takes a String or a NiftyImage, but I'm not sure how to create one without loading an image file.

Any help to understand this (if even possible) is appreciated. Thanks!


texts: Rotate directly towards a target at a constant speed

texts:
I've written a program (see on JS Fiddle) that rotates my player towards the mouse cursor at a constant speed. I've computed the angle to the point using the Math.atan2 function, but when incrementing or decrementing the player's rotation towards that value, it does not always take the shortest path.

This image describes the logic I intend to evaluate:

The problem appears when you cross a specific angle, the player rotates the long way around to reach the cursor, instead of taking the shortest path. How can I always take the shortest path at a constant speed?

Many thanks.


texts: How should I balance temporary buffs to make my game fun?

texts:
As a game developer, I understand many players (usually in RPGs) expect short term buffs to be available to them, such as potions, war cries, drugs, etc.

As a player, I've never understood what fun there is in using them. I think it's because they never seem to be very strong. They usually grant a 10-20% bonus to some attribute, for example -- just enough to turn a rage-quit situation into a merely-annoying one.

Maybe I just don't know how to use them; so how should I approach temporary buffs when balancing them? For the people who enjoy using them, what are they getting out of it? How might I go about confirming if my players agree that the mechanic is fun?


texts:
I'm trying to implement entity interpolation into my game. The structure is as follows:

Send the keypress states from the client to the server
Process the inputs and make calculations based on them
Send the state back to the client
On the clients end, store the previous state into a variable, then store the new state into a different variable
Interpolate between the the old state and the new state

However, I'm still getting jittering motion, and the interpolation seems to have no effect. Is this the correct method to interpolate entities, or should I go about this a different way?

//Client receiving data

socket.on('data', function (data) {
  old_data = current_data;
  current_data = data;
});
//Drawing the data using interpolation
for (var i = 0; i < current_data.length; i++) {
    fill(200);
    rect(current_data[i].x, current_data[i].y, 50, 50);
    var nx = lerp(old_data[i].x, current_data[i].x, 0.01);
    var ny = lerp(old_data[i].y, current_data[i].y, 0.01);
    //server updated player
    fill(33, 93, 10);
    rect(nx, ny, 50, 50);
}


texts: Not able to find the constraints option in the Rigidbody component

texts:
I am working on a game tutorial right now and I need to freeze constraints for a model prefab. I add a Rigidbody component and I want to freeze rotations on the x and z axes. However, I am not able to find the option in the component. Is there another way to access rotation constraints (I do not want to code the constraints at the moment)? Or is there something I am missing in the new version. Please do let me know. Thanks

I am using Unity 5.6.7f1 Personal


texts: Converting a quaternion in a right to left handed coordinate system

texts:
I have a quaternion from an IMU that id like to represent in unity. The issue is that the sensor uses a right handed coordinate system while unity uses a left handed coordinate system. In order to have the rotations of the IMU reflect in unity correctly, I would need to remap the axis. How can I do this by altering the quaternion components?

Specifically, I would need to map

         sensor   unity
forward  x        z
up       z        y
right    -y       x

I have seen multiple questions regarding this question especially this one.

Convert quaternion to a different coordinate system

However, it only explains a specific case where its a right hand to right hand remapping.

If possible, include an explanation without mathematics equations of how you would map any coordinate system to any other coordinate system.


texts: Where should my 3D character's pivot/anchor be?

texts: I created a 3d character with some animations a month ago and when testing the character in my game, I notice there are some weird interactions with the scenery that have me worried, particularly when climbing slopes and jumping over ledges. My character is a humanoid biped and his pivot point is his pelvis (it was the first bone I made for the armature in Blender). Should I have moved the pivot to the bottom of his feet? Does it matter? My character does NOT use "use root transform" in Unity; He was animated "in-place" in Blender and forces move him around (including jump trajectories) in Unity


texts: Make camera move constantly upwards in box2d world

texts:
Im using libGdx to develop a 2d game, which has the following:

The world moves in an upward direction by having a camera follow the player's y position.
The user only controls player's x movement, the y is a constant speed.

What i want to do now is let the user control the players x and y movement and let the camera move constantly up without following the player.

What is the best way to do this?

This is what i tried:

in Render()

player.body.setTransform(fingerPosition.x, fingerPosition.y, player.body.getAngle());

box2dCamera.position.y = box2dCamera.position.y + cameraSpeed;
box2dCamera.update();
box2dSpriteBatch.setProjectionMatrix(box2dCamera.combined);

This worked but all my collisions stopped working with other box2d bodies. Do i need to update each body in my game with the recalculated camera some-how? How would I do this?


texts: How do 3d engines add textures to objects?

texts:
I was wondering how 3d engines like Unity or OpenGL added textures to objects.

Example:

How would Unity add this texture to the side the arrow is pointing to?


texts:
Currently I'm trying to render a TileMap using OpenGL 2.1, GLSL 1.2.
I would like to draw every tile in just one draw call.
I use a single texture with all tiles, identifying each one by an index.

The vertex data per tile is:

vec2 worldPos; // the position to transform the tile Quad in world coordinates
vec2 texCoord; // the uv coordinates, calculated using the tile index, by CPU (top-left corner).

But I can't find a way to draw everything with one draw call:
    - The uv coordinates can't be calculated in shader because the vertex shader don't know which corner of the quad it is processing.
    - Can't draw by element because my quad vertex data only contains 4 vertices, store repeated vertices is a memory waste. Only if I could use a separate element buffer just for the vertex (0, 1, 2, 3, 0, 1, ...).

Does someone have any suggestion about how should I proceed?
Thanks!


texts: 2D how to add graphics for liquid physics?

texts:
I was always wondering how to add the graphics to a a blob body for example, regardless of what engine or library you are using, i want to know (theoratically) how to move from this state :
http://www.youtube.com/watch?v=qHvsER4Ou0w

to something like the blob in this video :
http://www.youtube.com/watch?v=ssOaZ3Lrov0

thank you


texts: Why does transform.forward appear to be void?

texts:
I have the following line of code from a project I'm working on:

this.transform.position += (keyMapping.Value * this.movementSpeed).Scale(this.transform.forward);

At a first glance, this line of code looks like it should work, yet, I get the following error when I try to run it:

error CS0019: Operator `+=' cannot be applied to operands of type `UnityEngine.Vector3' and `void'.

I'm stumped as to what might be causing this. How do I fix this?


texts: How to vectorize a raster image edges into SVG paths?

texts:
I'm having a lot of trouble figuring out how to convert a 2D list of points into an SVG Path representing a political map border. I have completed all parts of a 2D terrain generator, including climate simulation, rivers, lakes, rainfall, temperature, biomes, and finally territories. This last part is where the problem lies. The entire script is written in Python.

I have a list of territories, which are represented as dicts with several properties. One of which is Color, used as an ID and to output a pretty map. Another is a list of Pixels, list of Borders, and list of Neighbors. Pixels refers to all points in the territory. Territories can be thought of a polygons. They have Border pixels, which are defined as any outside (meaning not part of the Pixels list) pixel not belonging to this territory (whether it be a River, Ocean, or Unowned pixel). I also keep a list of neighboring territories.

Now, I can't store an array of ~3000 coordinates in a database efficiently when I only really need the border. I aim to draw only the world map with the borders of each territory drawn in a layer above. So I need to convert the border to an SVG Path string.

The Borders list is unordered when the generator finishes. For each border pixel, I go clockwise around the pixel and look for another, and progressively create a SVG Path string. I can't seem to efficiently parse the borders without getting stuck. Another problem is that there may be "lakes" in the middle of the Territory, and Borders are added around those as well. These don't have to be included in the path string.

Territories can also wrap around horizontally (like Google Maps for instance), splitting the territory in two.

So the final result of my algorithm would ideally be an LIST of SVG Paths, each representing individual parts of the territory polygons.

But, how do I do this efficiently? Is there another way to efficiently store a list of potentially thousands of coordinates representing the shape of the territory?

Each white line that sticks out from the coastline is a river. You can also see a lake in the middle of the lower green territory.

PS: I was unsure of a title, if a mod would like to change it.


texts: Pygame: circular motion with Bresenham's algorithm

texts:
I'm trying to figure out a way to move an object in a circular path. I read about Bresenham's circle algorithm, but all the codes available online draw an entire circle.

For my game, I want it so that when the ball enters a region, it'll begin to move in a circular path and when it leaves the region, it'll go back into moving in a straight path from its tangential velocity.

As of right now, I'm trying to figure out the algorithm to include in my game loop. I have the object updating its position every iteration. I use Bresenham's algorithm to decide whether to go right or go diagonal. I want it to draw the upper left portion of a circle

This is what I get:

Here is my code at the moment:

# Drawing Curves with Midpt Circle Theorem
import pygame, sys, random, math
from pygame.locals import *

class Game(object):
    def __init__(self):
        pygame.init()
        self.screen = pygame.display.set_mode((400,400))

        self.screen.fill((255, 255, 255))
        self.jom = pygame.Rect(100,100,2,2)

    def run(self):

        running = True

        while running:
            for event in pygame.event.get():
                if event.type == QUIT:
                    running = False
                elif event.type == KEYDOWN:
                    if event.key == K_ESCAPE:
                        running = False

            pygame.draw.rect(self.screen, (0,0,0), self.jom)

            ## Center of Curvature
            centercurv = (104,103)

            ## Update Position
                ## eqn of circle (x-104)**2 + (y-103)**2 - r**2 = 0, r == 5
            #circleeqn = (self.jom.x-centercurv[0])**2 + (self.jom.y-centercurv[1])**2
            #goright = (self.jom.x+1
            eR = -2*self.jom.x+2*centercurv[0]+1
            eD1 = -2*self.jom.x - 2*self.jom.y + 2*centercurv[0] + 2*centercurv[1] + 2
            print(eR,eD1)
            if abs(eR)-abs(eD1) > 0:
                #self.jom.x += 2
                self.jom.y -= 1
                print('1')
            elif abs(eR)-abs(eD1) < 0:
                #self.jom.x+=2
                print('2')
            else:
                if eR < 0 and eD1 < 0:
                    #self.jom.x+=2
                    print('3')
                elif eR > 0 and eD1 > 0:
                    self.jom.y -= 1
                    print('4')
            self.jom.x += 1

            pygame.display.flip()

        print('Quitting')
        pygame.quit()
        sys.exit()

if __name__ == '__main__':
game = Game()
game.run()


texts: Android Cocos2DX using C++ in Eclipse Helios Windows XP

texts: I have used Eclipse Helios 3.6.1 for Java development. I wanted to start C++ development in the same IDE so I installed Autotools Support For CDT, C/C++ Development Tools, C/C++ Library API Documentation Hover Help plugins.I have included #include "cocos2d.h" in my HelloWorldScene.h file now when writing the below statement cocos2d::CCSprite * ccSprite; I am not getting auto completion bar(template proposals) on writing like coco and pressing Ctrl + Space from my keyboard. What can be the problem?This might help you solve my problem. Please check here. This is what I got after clicking Right Click Project -> Index -> Search for Unresolved Index. But I have added all includes check here. I think this is causing problem in Content Assist. What should I do in this case? Inclusion seems proper.


texts: How to use facebook sdk on a cocos2dx-project

texts:
I'm doing a game cocos2d-x, when user gets a high score, I want them to touch on the Facebook icon and share the high score on their Facebook account timeline.

tutorials on facebook.developer.com using for objective-c project

Can anybody help me:(


texts: How can I do Mouse Selection In OpenGL 3.0?

texts:
Hello I'm pretty good programmer I've made my own 2D games in SDL and made a gui in 3D using Old OpenGL and Modern OpenGL but.. I'm having problems with trying to click 3D models with opengl I have no idea what to do too be honest.

Do I read the area that I've clicked?

or what do I do?

100% shore this has been asked before but I just don't know what to do...??

using :

OpenGL 3.0

WIN32 API

C++


texts:
I'm working on a game to learn the basic for game concepts. I end up with the following problem. I got a class called enemy, but now I want different types of enemies. These enemies extend from this class enemy. So I can have different enemies with that share different properties. The problem is that I want to spawn a different enemy each time. But to do this I need to know all the enemies available to choose on randomly.

I have been thinking and I got two approaches to solve this. The first one I end up is to have an enum with different enemies, and get a random value from the enum and spawn that enemy, but for this, I need to hard code all the enemies into the enum. And another one is to have a GameRegister class, that have a register for all available enemies, like when you do modding in Minecraft for example. I can have a registered class to register enemies or objects. And if I want to select a random enemy I know all the enemies available. I think is the best approach because if I want to add more enemies or anything, I only need to register for that class.

I don't have any idea at all to how to implement this pattern, and I didn't find anything on the internet. Can someone give some tips or clarify what I want to do? Because I have the main idea but I get completely lost when I need to design this.

I'm working on Java using libGDX, if is useful for some reason.


texts: Steering behaviours: collision avoidance with rectangles

texts:
I'm trying to implement collision avoidance steering behaviour using rectangles. Most of the tutorials I've found are with circles, and there's a substantial difference. For example, I've been reading this:http://gamedevelopment.tutsplus.com/tutorials/understanding-steering-behaviors-collision-avoidance--gamedev-7777

My current approach: first, detect the nearest rectangle as done in the article. I create a point called ahead in front of my entity and then check if that point is inside the rectangle.
After calculating the nearest object, I decompose my rectangle in a set of points, equally spaced in the rectangle walls. My entity will flee those points.

EDIT: I've also proven to convert my rectangle in an electromagnetic repulsive rectangle with 4 bars of homogeneus charged. It didn't worked.
I also tried the "containment" section described in Craig Reynolds' website and it also didn't worked properly.

That works reasonably well: my entities try to avoid the rectangle. However, they sometimes get a bit into it, and when they're near the rectangle they start flipping to left and right quickly. That is not a very natural behaviour, so I think I want to prove another thing.

I've read this in gamedev SO: Wall avoidance steering I think that this could be what I need, approximately. However, I need some guidance on this.

First, the answer speakes about a dot product of the wall-boid vectors (let's call them WBi). Which is the another vector I have to multiply with? In the code sample is noted as partsList but I don't know what it is.
So, first question: what is this second vector?
In my opinion, this algorithm as a very important flow. If the force is exerted in the direction of normal of the wall, and by chance my entity goes with velocity normal to the wall, it will stop. This, I think, could be a rare event because more steering forces are involved...
Second question: there is a way to avoid this? Is this effect important enough to take care of it even if I have more forces?
In fact, I need an algorithm capable of detecting and avoding rectangles with steering behaviors -or, at less, a way to move my entities in a space with obstacles using something compatible with steering behaviors, because I use them for coordinate movement.

Take in account that some combinations of rectangles could create convex shapes.

EDITS:

The rectangles aren't rotated.


texts: How to set a Label position after a timer ends, in a repetitive structure?

texts:
I have this fragment of code. It moves a pawn on a board.

while(i<end)
{
    try
    {
        Thread.sleep(1000);
    }
    catch (Exception e)
    {
       System.out.println(e);
    }
    Label.setBounds(x+i, y, xsize, ysize);
    i++;
}

My problem:
The Label gets set only once, after all the time(end seconds) passes.

Also tried:
1:

while(i<end)
{
    for(int v;v<9999999;v++);
    Label.setBounds(x+i, y, xsize, ysize);
    i++;
}

2:

while(i<end)
{
    for(int v;v<9999999;v++)
    {
        Label.setBounds(x+i, y, xsize, ysize);
    }
    i++;
}

With same result.


texts: Interpolate camera rotation over many keyframes smoothly

texts:
I have a defined set of rotation/position keyframes that I want a camera to animate between smoothly.  Handling the position is easy enough using cubic bezier curves (and just auto-generating the control points between each keyframe).  But after a day of research I'm still having a lot of trouble figuring out how to handle rotation similarly.

My first thought was that there must be a similar way to do it using bezier curves, except applied to quaternions instead of 3d vectors.  I found a bunch of research papers on the subject, but as is so often the case with research papers, actually implementing them is another story entirely (and frustratingly, source code is never provided).  So if anyone with experience in this stuff could give me some direction as to the best approach here I'd really appreciate it


texts:
I have a Unity project which requires a bunch of Canvases and, surprise surprise, they're creating a lot of lag. I've already turned off the graphics raycaster for every single one, but they still drop so many frames.

Are there any good alternatives to draw text in the worldspace that are a lot more efficient? (I'm targeting mobile, so this is important).


texts: Prevent replay attacks on multiplayer character movement

texts:
When a client first connects to the server a Diffie-Hellman key exchange occurs to securely get private encryption keys to encrypt all packets.

The problem comes in: what if someone sniffing packets resend a "move right" command? Since they are simply resending the packet the encryption is still correct, and since movement commands can come at anytime, multiple times, the server cant just ignore multiple of the same packets.

Q: How do i prevent a packet-sniffer from replaying a move-right player command.

Edit: would the answer be timestamps included in the encrypted message? and then maybe any movement commands that are older then 500ms are dropped?


texts:
I made a pc game recently (uni project) and now I want to put it on google market but I am having troubles changing original controls to touchscreen. The problem is that I don't really know what I can use for controls (tap, double tap, etc.) so the app is really easy to use. I will be incredibly grateful if you could share ideas for what types of controls can be used for my game.

The player controls a shield, which moves around the inner circle (originally the object follows mouse cursor). The player can also shoot with the shield to destroy obstacles, so the bullet is created inside the shield and then travels in the direction the shield was facing (the bullet is created on mouse click).

In the mobile version, the player controls the shield with his finger. It creates two problems: the player is not able to see some of the obstacles because his hand covers some parts of the screen. Also, it means I cannot use simple tap (or at least I don't know how) for shooting, which makes the controls unintuitive.
To shoot the player has to touch the screen with two fingers. It is not a common gesture, so people won't think of using it straight away unless told what to do. And the main point of my game is that there are no words at all and people are expected to understand controls without any tutorials.
Also, the game relies on quick reactions, so controls cannot be complicated.

Thank you!


texts: Which data structure should I use for  dynamically generated platforms?

texts:
I'm creating a platform type of game with various types of platforms. Platforms that move, shake, rotate, etc. Multiple types and multiple of each type can be on the screen at once. The platforms will be procedural generated.

I'm trying to figure out which of the following would be a better platform system:

Pre-allocate all platforms when the scene loads, storing each platform type into different platform type arrays( i.e. regPlatformArray ), and just getting one when I need one.
The other option is to allocate and load what I need when my code needs it.

The problem with 1 is keeping up with the indices that are in use on screen and which aren't.

The problem with 2 is I'm having a hard time wrapping my head around how I would store these platforms so that I can call the update/draw methods on them and managing that data structure that holds them. The data structure would constantly be growing and shrinking. It seems there could be too much complexity.

I'm using the cocos2d iPhone game engine.

Anyways, which option would be best or is there a better option?


texts:
I'm trying to do the examples within the GameDev.net Beat Detection article ( http://archive.gamedev.net/archive/reference/programming/features/beatdetection/index.html ) I have no issue with performing a FFT and getting the frequency data and doing most of the article. I'm running into trouble though in the section 2.B, Enhancements and beat decision factors.

in this section the author gives 3 equations numbered R10-R12 to be used to determine how many bins go into each subband:

R10 - Linear increase of the width of the subband with its index

R11 - We can choose for example the width of the first subband

R12 - The sum of all the widths must not exceed 1024

He says the following in the article: "Once you have equations (R11) and (R12) it is fairly easy to extract 'a' and 'b', and thus to find the law of the 'wi'. This calculus of 'a' and 'b' must be made manually and 'a' and 'b' defined as constants in the source; indeed they do not vary during the song."

However, I cannot seem to understand how these values are calculated...I'm probably missing something simple, but learning fourier analysis in a couple of weeks has left me Decimated-in-Mind and I cannot seem to see it.


texts: Texturing 2D vectorial terrain (or simply masking texture)

texts:
I have a procedurally generated terrain, as follows:

It is generated and then built using Farseer Physics, however I haven't found a way to create and apply a mask to texture it properly, I have already played with stencil buffers and pixel shaders but I still have no solution at the moment. How would I do that? Am I going the right direction with stencil and pixel shader? Thank You.


texts:
If player's browser don't support WebGL, I want to redirect Web Player version. I think it's possible in UnityLoader.js file but how?

function CompatibilityCheck(){hasWebGL?mobile?confirm("Please note that Unity WebGL is not currently supported on mobiles. Press Ok if you wish to continue anyway.")||window.history.back():-1==browser.indexOf("Firefox")&&-1==browser.indexOf("Chrome")&&-1==browser.indexOf("Safari")&&(confirm("Please note that your browser is not currently supported for this Unity WebGL content. Try installing Firefox, or press Ok if you wish to continue anyway.")||window.history.back()):(alert("You need a browser which supports WebGL to run this content. Try installing Firefox."),window.history.back())}

I just want to add a URL redirect here.


texts:
After i press and hold the key it goes forward once then pauses for a second or less then goes forward on forever. My problem is the brief pause I cant locate the issue. Thanks for your help.

    while(game){
        while (SDL_PollEvent(&e)){
            mainChar.manageEvents(e);
        }
        background.renderChar();
        mainChar.renderChar();
        SDL_RenderPresent(ren);

    }
void Character::manageEvents(SDL_Event event)
{
    switch(event.type){
        case SDL_KEYDOWN:
            KEYS[event.key.keysym.sym] = true;
            printf("true");
            handleInput();
            break;
        case SDL_KEYUP:
            KEYS[event.key.keysym.sym] = false;
            printf("false");
            break;
        default:
            break;
    }
}
void Character::handleInput()
{
    if(KEYS[SDLK_a]) {
        dst.x--;
    }
    if(KEYS[SDLK_d]) {
        dst.x++;
    }
    if(KEYS[SDLK_w]) {
        dst.y++;
    }
    if(KEYS[SDLK_s]) {
        dst.y--;
    }
}


texts: Creating Platform game with Inclined Levels

texts:
Till now I have developed platform games in which a player can only move and detect tiles linearly. I wonder on how to implement games
in which a player can move on an inclined or irregular surface.

I use libgdx to develop games and Tiled Map Editor to create level maps.

On research, I found RUBE is something I need for what I want to do.

Is this true? I will have to use Box 2D if I want to make such games.

Can't we do it using Tiled? If so... how to detect collision in that case?

If there is some other way through which I can do so? Thanks in advance for any suggestion.


texts: How do I hide the camera object in Unity Editor

texts:
I have 2019 Unity Editor
I have a huge camera object that is blocking all the other objects that I need to move in the scene,
I want to hide this object, but I cannot find a hide/show menu item anywhere or when I right click on the hierarchy


texts: Unity 2D - Object following target instead of moving towards it

texts:
I'm making a 2D game with Unity that's based on avoiding/evading enemies.
The problem i'm facing right now is i can't get the enemies to move towards the target/player, but instead they follow it. So they never actually "attack" because they only follow it around and don't even come close to it. Also if the target/player stops moving, they stop moving.

I'm wondering if it could be something in my scene, since i've asked this question on multiple forum threads in the unity forums section and everyone seems to answer with the same lines of code.

Extra information:

My enemy has a box collider on it with no rigidbody 2D.
My player has a box collider on it with a rigidbody 2D.

Kind regards.

using UnityEngine;
using System.Collections;

public class BeeBehaviour : MonoBehaviour {

  public Transform target;
  public float moveSpeed = 3;

  void Start () {
    target = GameObject.Find("MainObject").transform;
  }

  void Update () {
    Chase();
  }

  void Chase () {
        Vector3 targetDirection = target.position - transform.position;
        transform.position += targetDirection * moveSpeed * Time.deltaTime;
  }
}


texts: Euler angle and Quaternion conversion become weird when yaw is bigger than 90 degrees

texts:
I'm writing a camera which needs to change a quaternion to Euler angles than change them back, it only works when the yaw is less than 90 degrees, I wrote a example to check:
glm::vec3 euler_angler = {0, 0, 0};
  for (int i = 0; i < 91; i++) {

    std::cout << "before: " << euler_angler.x << ", " << euler_angler.y << ", " << euler_angler.z << std::endl;

    euler_angler.y += 1;

    glm::quat quat({glm::radians(euler_angler.x), glm::radians(euler_angler.y), glm::radians(euler_angler.z)});

    glm::vec3 new_euler_angler = glm::eulerAngles(quat);

    std::cout << "after: " << glm::degrees(new_euler_angler.x) << ", " << glm::degrees(new_euler_angler.y) << ", "

              << glm::degrees(new_euler_angler.z) << std::endl;

  }

and when the Euler angles is {0, 89, 0}, then the Euler angles changed back to quat is the same, which is {0, 89, 0}, but when the origin changes to {0, 90, 0}, the new_euler_angler suddenly becomes to {180, 89.0001, 180}, and makes my camera rotation a mess.
Can someone help why this happened and what should I do?
the code of my camera:
glm::vec3 euler_angler = glm::eulerAngles(transform_data.rotation);
euler_angler.x = euler_angler.x + glm::radians(delta_y);
euler_angler.y += glm::radians(delta_x);
euler_angler.z = 0;
transform_data.rotation = glm::quat(euler_angler);

and here's my calculation of view matrix(which is a suspect because all other tutorials are using lookat matrix, I'm not sure my way is right or not):
// the position and rotation of the camera
auto transform_data = actor_.GetTransform().GetData();
glm::mat4 view = glm::mat4(1.0f);
view = glm::translate(view, -transform_data.position);
view = glm::toMat4(glm::quat(transform_data.rotation.w,
                               -transform_data.rotation.x,
                               -transform_data.rotation.y,
                               -transform_data.rotation.z)) * view;
render_camera_.SetViewMatrix(view);
glm::mat4 projection;
projection = glm::perspective(glm::radians(fov_), (float) aspect_, 0.1f, 100.0f);
render_camera_.SetProjectionMatrix(projection);


texts: Is this a good approach for me to design the classes in my game?

texts:
I was searching for XNA tutorial in Youtube and I found this
http://www.youtube.com/watch?v=MxucTn2HYxY

I was wondering if this is a good way to design the overall structure/classes for my game I'm trying to do. Basically, my game is almost the same as what this tutorial teaches ( A top down shooter ) , except that mine has inventory system.
And is this some sort of design pattern or something? I can't really identify it IF it is...

For code example,

class Obj  {
    public Obj(Vector2 pos) {
        this.pos = pos;
    }
    public virtual void LoadContent(ContentManager Content) {
        // Load Texture , spriteIndex
    }
    public virtual void Update() {
        // Update
    }

    public virtual void Draw(SpriteBatch sb) {
        // draw
    }
}

class Items  {
    public static List<Obj> objList = new List<Obj>();

    public static void Initialize() {
        for (int i = 0 ; i < 64; i++ ) {
            Obj o = new Bullet(Vector2.Zero);
            o.alive = false;
            objList.Add(o);
        }
        objList.Add(new Wall(new Vector2(100, 120)));
        objList.Add(new Wall(new Vector2(550, 130)));
        objList.Add(new Man(new Vector2(50, 50)));
        objList.Add(new Cursor(new Vector2(50, 50)));
    }
}

class Man : Obj  {
    public Man(Vector2 pos) : base(pos)
    {
        pos = this.pos;
        speed = 2;
        spriteName = "P";
    }

    public override void Update() {
        // Update
        base.Update();
    }

    public override void Draw(SpriteBatch sb) {
        // Draw the HUD
        base.Draw(sb);
    }
 }


texts: how should I network my turn based game?

texts:
I'm writing a very basic turn based strategy game which allows a player to select units and attack enemy units on their turn. The game is written in Java using the slick2d library and I plan to use kyronet for the networking api.

I want the game to be networked, but I do not know how I should go about it. My current idea is to connect two users together, and the first one to join the game becomes the game host, while the other becomes the client.

However after reading http://gafferongames.com/networking-for-game-programmers/what-every-programmer-needs-to-know-about-game-networking/ it seems my game would be suited to a peer to peer lockstep model. Would that make programming the networking side much easier?

Any suggestions on how I should structure my networking would be greatly appreciated


texts: Approaches on 2D top-view racing game track design

texts: I've finished programming the car (acceleration, etc) and now I'll start developing a track editor of some sort. The thing is: I have no idea how I'm going to do that. How would you do it? Perhaps design the tracks on GIMP and use some sort of pixel collision detection, or perhaps use multidimensional arrays to store track data like walls and "dirt". I'm open to suggestions.


texts: How can I check it if a line3D/ or ray is intersecting a sphere?


texts: Am I on the right track with this component architecture?

texts:
I've recently decided to revamp my game architecture to get rid of deep class hierarchies and replace them with configurable components. The first hierarchy I'm replacing is the Item hierarchy and I would like some advice to know if I'm on the right track.

Previously, I had a hierarchy that went something like this:

Item -> Equipment -> Weapon
                  -> Armor
                  -> Accessory
     -> SyntehsisItem
     -> BattleUseItem -> HealingItem
                      -> ThrowingItem -> ThrowsAsAttackItem

Needless to say it was starting to get messy and these was no easy solution to items that needed to be multiple types (i.e. some equipment is used in item synthesis, some equipment is throwable, etc.)

I then attempted to refactor and place functionality into the base item class. But then I was noting that the Item had alot of unused/superfluous data. Now I'm trying to do a component like architecture, at least for my items before attempting to do so to my other game classes.

Here's what I'm currently thinking for the component setup:

I have a base item class that has slots for various components (i.e. an equipment component slot, a healing component slot, etc. as well as a map for arbitrary components) so something like this:

class Item
{
    //Basic item properties (name, ID, etc.) excluded
    EquipmentComponent* equipmentComponent;
    HealingComponent* healingComponent;
    SynthesisComponent* synthesisComponent;
    ThrowComponent* throwComponent;
    boost::unordered_map<std::string, std::pair<bool, ItemComponent*> > AdditionalComponents;
}

All item components would inherit from a base ItemComponent class, and each Component type is responsible for telling the engine how to implement that functionality. i.e. the HealingComponent tells the battle mechanics how to consume the item as a healing item, while the ThrowComponent tells the battle engine how to treat the item as a throwable item.

The map is used to store arbitrary components that are not core item components. I'm pairing it with a bool to indicate whether the Item Container should manage the ItemComponent or if it's being managed by an external source.

My idea here was that I define the core components used by my game engine up front, and my item factory would assign the components that the item actually has, otherwise they are null. The map would contain arbitrary components that would generally be added/consumed by scripting files.

My question is, is this a good design? If not, how can it be improved? I considered grouping all components into the map, but using string indexing seemed unecessary for the core item components


texts: How to calculate “real” distance between cursor and distant object?

texts:
I don't really know how to formulate the title, but the problem is the following:

I'm using a scripting language called "SQF" which has been created by a company named "Bohemia Interactive" (no, I do not work for them) and it's for modding their games. So I won't fill up these lines with code. If somebody else knows it and wants to see, comment and I'll add what I've tried so far.

The issue anyway is rather abstract, so I'm going to explain it with an archer and his target. Ratios may not be correct as they are only for explanation.

Say I (as the player) am the archer (first person), the target is 10m away, has a diameter of 2m and appears 200px in diameter on the screen. Now I aim 50px left of the target edge, execute my desired function and and get the info that this is 1m away from the target (2m from its center).

Now, I move 90m back, so the target is 100m away and appears 100px in diameter (don't know if that's correct, but you get the idea). Now I am aiming 25px left of the target and again, execute my desired function and it should tell me again that the distance is 1m.

Now, the "real" distance was 1m in both cases, but on my screen it was 50px at the first aim and 25px at the second.

So, what I am looking for is a (mathematical/programmatical) model to get the "real" distance between the target and where I aimed, no matter how far away I was from the target. I do have the positions of both archer and target in 3D coordinates. Though SQF is a very special language, it does provides a function to calculate the distance in meters and to dertermine certain geometrical values:

https://community.bistudio.com/wiki/Category:Command_Group:_Math

... so there's no need for that.

I know, this is very abstract, but I am hoping, somebody could give a hint or knows a mathematical procedure to do that.

If somebody knows how to do it in C, C++ or Java, I can write these languages, so that would be great!


texts: How do I implement a quaternion based camera?

texts:
UPDATE The error here was a pretty simple one. I have missed a radian to degrees conversion. No need to read the whole thing if you have some other problem.

I looked at several tutorials about this and when I thought I understood I tried to implement a quaternion based camera. The problem is it doesn't work correctly, after rotating for approx. 10 degrees it jumps back to -10 degrees. I have no idea what's wrong. I'm using openTK and it already has a quaternion class. I'm a noob at opengl, I'm doing this just for fun, and don't really understand quaternions, so probably I'm doing something stupid here. Here is some code: (Actually almost all the code except the methods that load and draw a vbo (it is taken from an OpenTK sample that demonstrates vbo-s))

I load a cube into a vbo and initialize the quaternion for the camera

protected override void OnLoad(EventArgs e) {
    base.OnLoad(e);

    cameraPos = new Vector3(0, 0, 7);
    cameraRot = Quaternion.FromAxisAngle(new Vector3(0,0,-1), 0);

    GL.ClearColor(System.Drawing.Color.MidnightBlue);
    GL.Enable(EnableCap.DepthTest);

    vbo = LoadVBO(CubeVertices, CubeElements);
}

I load a perspective projection here. This is loaded at the beginning and every time I resize the window.

protected override void OnResize(EventArgs e) {
    base.OnResize(e);

    GL.Viewport(0, 0, Width, Height);

    float aspect_ratio = Width / (float)Height;

    Matrix4 perpective = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspect_ratio, 1, 64);
    GL.MatrixMode(MatrixMode.Projection);
    GL.LoadMatrix(ref perpective);
}

Here I get the last rotation value and create a new quaternion that represents only the last rotation and multiply it with the camera quaternion. After this I transform this into axis-angle so that opengl can use it. (This is how I understood it from several online quaternion tutorials)

protected override void OnRenderFrame(FrameEventArgs e) {
    base.OnRenderFrame(e);

    GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

    double speed = 1;
    double rx = 0, ry = 0;

    if (Keyboard[Key.A]) {
        ry = -speed * e.Time;
    }

    if (Keyboard[Key.D]) {
        ry = +speed * e.Time;
    }

    if (Keyboard[Key.W]) {
        rx = +speed * e.Time;
    }

    if (Keyboard[Key.S]) {
        rx = -speed * e.Time;
    }

    Quaternion tmpQuat = Quaternion.FromAxisAngle(new Vector3(0,1,0), (float)ry);
    cameraRot = tmpQuat * cameraRot;
    cameraRot.Normalize();

    GL.MatrixMode(MatrixMode.Modelview);
    GL.LoadIdentity();

    Vector3 axis;
    float angle;

    cameraRot.ToAxisAngle(out axis, out angle);
    //////////////////////////////////////////////////////////////////////
    // THIS IS WHAT I DID WRONG: I NEED TO CONVERT FROM RADIANS TO DEGREES
    //////////////////////////////////////////////////////////////////////
    //BEFORE
    //GL.Rotate(angle, axis);
    //AFTER
    GL.Rotate(angle * (float)180.0/(float)Math.PI, axis);
    GL.Translate(-cameraPos);

    Draw(vbo);
    SwapBuffers();
}

Here are 2 images to explain better:
I rotate a while and from this:

it jumps into this

Any help is appreciated.

Update1: I add these to a streamwriter that writes into a file:

    sw.WriteLine("camerarot: X:{0} Y:{1} Z:{2} W:{3} L:{4}", cameraRot.X, cameraRot.Y, cameraRot.Z, cameraRot.W, cameraRot.Length);
    sw.WriteLine("ry: {0}", ry);

The log is available here: http://www.pasteall.org/26133/text. At line 770 the cube jumps from right to left, when camerarot.Y changes signs. I don't know if this is normal.

Update2 Here is the complete project.


texts: Rendering different materials in a voxel terrain

texts:
Each voxel datapoint in my terrain model is made up of two properties: density and material type.  Each is stored as an unsigned integer value (but the density is interpreted as a decimal value between 0 and 1).  The density values are used to generate a mesh with the marching cubes algorithm.

My current idea for rendering these different materials on the terrain mesh is to store eleven extra attributes in each vertex:  six material values corresponding to the materials of the voxels that the vertices lie between, three decimal values that correspond to the interpolation each vertex has between each voxel, and two decimal values that are used to determine where the fragment lies on the triangle.

The material and interpolation attributes are the exact same for each vertex in the triangle.  The fragment shader samples each texture that corresponds to each material and then uses the aforementioned couple of decimal values to interpolate between these samples and obtain the final textured color of the fragment.

It should work fine, but it seems like a big memory hog.  I won't be able to reuse vertices in the mesh with indexing, and each vertex will have a lot of data associated with it.  It also seems pretty slow.  What are some ways to improve or replace this technique for drawing materials on a voxel terrain mesh?


texts: How can I model the physics of an air blower?

texts:
I want to model simple lottery machine, it has got a bottom blower.

Do you know how can I get force applied to object above blower by air from blower, or equations to model this behavior?

Red arrow is blower "wind"


texts: How to make an oscillation move on opengl qt

texts:
I'm trying to make a character make an oscillation move. That is, the character will start by rotating to a certain angle, say 60 degrees, and then slowly come back to an upright position then rotate to the opposite direction for an angle less than 60, say 55, and do it all again until the rotation angle reaches zero and the character stops. Currently I'm trying to achieve this by declaring global variables and checking them with if blocks and changing their value by 1 degrees in those blocks so that each time the timer calls paintgl it decreases the angle by 1 degree and draws the object thus making it look like it's slowly rotating. I'm having trouble with stopping the character. This is the part of my code that handles it;

glRotatef(j,0,1,0);
glRotatef(k,0,1,0);

if(flag)
{
j = j + 2;
 if (j == 0)
 {
   k = 60;
   flag = !flag;

}
}

if(!flag)
{

k = k - 2;
if(k == 0)
{
    j = -60;
    flag = !flag;
}
}

gluCylinder(player, 1,1,8,100,100);
Here the cylinder is my character and the if blocks are increasing/decreasing the global variables j and k. j is initialized to -60 and k is initialized to 60.

what i want to do is to make the character lean to the ground for an angle by the click of a mouse and when the mouse is released, the character will slowly go upright and lean on to the other direction, then slowly go upright again and lean on to the first direction and so on.

How can I make this thing work and how can I stop it. Thanks in advance.


texts: Transform check should return null, but returns as initialized instead

texts:
In my Player script, I initialize my FirePoint transform using GameObject.Find in the Awake function. In the editor, I purposely misspelled the name of FirePoint to test if the null check inside of my Fire function will print an error to the console. The only error that shows up is from the Awake function giving a NullReferenceException, but why don't I see my Debug.LogError? Instead, the else statement prints that the FirePoint is not null.

public class Player : MonoBehaviour
{

   [HideInInspector] public Transform FirePoint;

   private void Awake()
   {
       FirePoint = GameObject.Find("FirePoint").transform;
   }

   private void Fire()
   {
       if (FirePoint == null)
       {
           Debug.LogError("FirePoint is null.");
       }
       else
       {
           print("FirePoint is NOT null.");
       }
   }
}


texts: How can I resize a Surface object in Pygame? Is there a way to bind a surface object into a Rect object, so that resizing the rect would also resize the surface (with Rect.inflate_ip method for an example)?


texts: How do games programmatically manipulate 3d models?

texts: The title says it all. An artist makes a 3d model of a character. How does a programmer use the model to make the character run around?


texts:
I've made a few games which I've actually released into the wild. There's one particular issue I run into over and over, and that's the issue of the interface/theme of the game.

How can you make non-arbitrary, consistent decisions about the look-and-feel and interface of your game?

For example, in version one of my Silverlight chemistry-based game, I made a (bad?) decision to go witha  natural, landscape-style look-and-feel, which resulted in this UI:

Then in a later iteration, I got smarter and went with a more "machiney," grungy look-and-feel, which resulted in this (final UI):

I will definitely say that my taste in UI improved through iteration. But it was a result of a lot of initially arbitrary decisions followed by a lot of tweaking.

Is there a better way to figure out how to theme your game?

To give a parallel in writing, when you're writing a fantasy/sci-fi novel, there are a lot of elements you need to describe. While you can arbitrarily invent objects/creatures/places/etc., you get a much more consistent world when you sit down for a few minutes and design the area, region, planet, or universe. Everything then fits together nicely, and you can ask yourself "how would this work in this universe?

Edit: It seems like I didn't explain this well. Let me simplify the question in the extreme: when I need to lay out a title screen (with background, fonts, skinned buttons) how do I decide how they should look? Green or blue? Grunge or not? Rounded or flat? Serif or sans-serif?

Take that question and explode it into your game as a whole. How do you figure out how things should look? What process do you use to make them consistent and non-arbitrary?

Look at the screenshots again. I could have stuck to grass/sky/rocks, but metal seemed more fitting to the idea of chemical reactions and atoms.


texts: User magic creation system that isn't programming

texts:
I would love to create an RPG with a magic system in it that gives the player a LOT of freedom.

To the extent they can make their own spells, systems of magic etc., bind spells to items, and so on.

Spells and magic would obviously have constraints, but doing lots of research into magic, and spending time creating spells etc. should allow players to create more and more powerful spells.

I'm really struggling how to come up with an interface through which they can create spells that isn't directly similar to programming. I don't want it to be so simple/boring as typing a sequence of commands that get triggered by clicking on a wand and calling that a spell.

I would love it if it were less human-intuitive, linearity combinations etc. weren't obvious or easy to figure out, and it was possible to explore the magic system deeply to discover more complex ways to piece together magics.

Are there any precedents? Does anyone have any ideas on how such a system could be implemented?


texts: Pygame bullet firerate not working sometimes

texts:
i have made this bullet class but i have a problem with the firerate. Sometimes  i'm not able to shoot even when the little delay (700ms) between the two shots has ended. I guess it's due to the pygame.time.set_timer(). Anyways i'm looking for a quick solution because i wanna move on to work on another part of this game.
...

class Singlebullet(object):

    def __init__(self):
        self.img = pygame.image.load(r'C:\Users\Salem\Documents\MyGame1\bullet.png')
        self.state = 'ready'
        self.speed = 0
        self.firerate = 700

    def shoot(self):
        if current_bullet_type == 'single':
            if self.state == 'ready':
                self.x = myplane.x + 71
                self.y = myplane.y
            if self.state == 'fire':
                self.speed = -13
            for event in events:
                if event.type == pygame.KEYDOWN or event.type == pygame.KEYUP:
                    if event.key == pygame.K_SPACE:
                        self.state = 'fire'
                        pygame.time.set_timer(pygame.USEREVENT+1, self.firerate)
                if event.type == pygame.USEREVENT+1:
                    self.state = 'ready'
            MyScrollingScreen.blit(self.img, (self.x, self.y))
            self.y += self.speed
s1 = Singlebullet()
...
while running:
    ...
    s1.shoot()
    ...


texts:
I have some 3d models that I have downloaded from Unity asset store. Most of the time, these objects are not "separatable" so I can't apply a destructible effect.

Is there a way to separate a model into small pieces, whether by using Blender, or a Unity script, or something else?


texts: Move a 2D square on y-axis on Android GLES2

texts:
I am trying to create a simple game for Android. To start, I am trying to make the square move down the y-axis, but the way I am doing it, it doesn't move the square at all and I can't find any tutorials for GLES20.

The onDrawFrame function in the render class updates the user's position based on acceleration due to gravity, gets the transform matrix from the user class which is used to move the square down, then the program draws it.

All that happens is that the square is drawn; no motion happens:

public void onDrawFrame(GL10 gl)
{
    user.update(0.0, phy.AccelerationDewToGravity);
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); // Re draws black background

    GLES20.glVertexAttribPointer(maPositionHandle, 3, GLES20.GL_FLOAT, false, 12, user.SquareVB);//triangleVB);
    GLES20.glEnableVertexAttribArray(maPositionHandle);
    GLES20.glUniformMatrix4fv(maPositionHandle, 1, false, user.getTransformMatrix(), 0);

    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);

}

The update function in the player class is

public void update(double vh, double vv)
{
    Vh += vh; // Increase horrzontal Velosity
    Vv += vv; // Increase vertical velosity

    //Matrix.translateM(mMMatrix, 0, (int)Vh, (int)Vv, 0);
    Matrix.translateM(mMMatrix, 0, mMMatrix, 0, (float)Vh, (float)Vv, 0);
}


texts: How to make an enemy spawner that selects from a list of potential enemies? (Unity)

texts:
I'm just making a practice version of a basic 2D RPG, but I'm trying to build a spawner kind of object that could be scaleable across the entire game. That is, there would be multiple types of enemies, and each instance of such a spawner would have a specific set of enemies that it would spawn.

I'm sure the answer is very simple, but I'm at the beginning stages of all of this. I guess really I just want a simple list that I can attach to my object and add the enemy names to it so that it can draw from that to figure out what they would spawn.


texts:
Me and some friends developing simple 3D rendering engine as practice for the university.
We used Ogre 3d as prototype and now we are developing it from base

The engine is wrapped up in simple game that asks the user to select shape (circle, triangle, square...), color and dimensions and renders the image to the screen. It also enables to move and rotate the shape on screen using mouse.

We would like to test automate the view rendering.
I could not find any test framework for this issue and I would like to know how 3D test is done in non manual matter


texts: How to Make GameObject move in Circular Motion

texts:
I've been trying to work an enemy that moves in a circular motion for my RPG game, but for some reason, whenever I press play the GameObject instantly goes hundreds of units in the X and Y coordinates. It also move back to -1 on the Z axis. Here's the script to my enemy's movement:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyScript : MonoBehaviour
{

    private Rigidbody2D rb;

    [SerializeField]
    float rotationRadius = 2f, angularSpeed = 2f;
    float posX, posY, angle = 0f;

    // Start is called before the first frame update
    void Start()
    {
        // Gets the RigidBody2D component
        rb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        Movement_1();
    }

    void Movement_1()
    {
        posX = rb.position.x + Mathf.Cos(angle) + rotationRadius;
        posY = rb.position.y + Mathf.Sin(angle) + rotationRadius;
        transform.position = new Vector2(posX, posY);
        angle = angle + Time.deltaTime * angularSpeed;

        if (angle >= 360f)
        {
            angle = 0f;
        }
    }
}


texts: What would be the things to consider translating a game?

texts:
I suppose this is not rather common subject to bring on at this site, as it seems that most of them are related to programming; however, I wanted to ask you what would be the things to consider when translating the story(text) of a game, say, into English.
Could you give me guideline which I can work with - guideline that consists of things to consider and priorities of each thing? For example:
High Priority:

Consistency of how characters say throughout the game.
Typos
The most important ones.

Mid Priority:

These should be fulfilled in order to be a "pleasantly playable" game.

Low Priority:

Things that can be ignored if the time does not allow.

EDIT: For someone who may be interested in this question in the future, here is the list you can refer to.
Grammar: Pronouns, Prepositions, Wrong conjunction, Articles, Typos, Wrong tense, Inconsistent tense in a sentence, Too academic vocabulary
Style: Inconsistent accent and way characters say, Inconsistent style of text throughout the whole story, Awkward phrases, Wrongly spelled character name, Inconsistent spelling of the name of a character, Style not matching with a character(A commoner talking like a knight)


texts:
I'm moving my sprites using the following formula:

Code that I'm using (Only shows sprite's X position being calculated but Y position is also being done)

spriteGridX = 240/480;  //I start out with a virtual 'Grid' so I can scale position to all resolutions etc so 240/480 would place the sprite at the center of the screen (X)

spriteScreenX = spriteGridX * width;  //Scale to physical screen where width is the width of the current devices screen (viewport)

spriteXTime = 8f; //8 being the amount of time in seconds that this sprite will take to traverse the entire width of the screen

spriteXVel = 1/spriteXTime; //Velocity that will be used to move the sprite along the virtual grid position

So, when I need to move the sprite, I simply do the following:

spriteXGrid+= (spriteXVel * Delta) //+= for right -=for left. I'm using a fixed delta time
spriteScreenX = spriteGridX * width; //And again, convert to usable screen position for current device
drawsprite(spriteScreenX, SpriteScreenY); //Draw the sprite (drawSprite is just a method I've written to draw openGL quads and it takes the screen X and Y as coordinates - spriteScreenY not shown here but essentially same as X with height instead of width.

Problem

The above seems to work OK (if I specify, as above, 8seconds, then the sprite does indeed take 8seconds to pass the whole screen as far as I can tell).

However, a problem becomes evident when I have 2 sprites (in my case, 2 horizontally moving platforms, both starting at the outer edges of the screen - one on the left and one of the right) - these move towards each other and when they 'meet', they go back in the opposite direction, and again when they reach their initial starting positions.

After the second time, they start to move slightly out of sync and the problem accumulates.  Each platform has the same time/velocity settings and it seems that a sprite over the right side of the screen moves at a very slightly different speed than the one on the left.

After the initial move, the difference between the grid positions of my 2 sprites are a follows:

Left sprite = 0.002083334
Right sprite = 0.0020834

I can't work out why there is a difference.  They're using the same formula.

Of course the problem could be that they are reversing at slightly different times and not the speed as I suspect, but for now I've ruled that out as they seem to be reversing correctly.

Be grateful if anyone could assist.  Thanks

Test Device: Google Nexus 10, Samsung Galaxy Ace v1


texts:
I know this question has been asked several times but none of the answers solved my problem.

I made an sphere and gave it rigidbody. then I draged the sphere on to a new made prefab.

on mouse-click Instances of this prefab are made and shot. the spheres collide with things in the scene but the onCollisionEnter function is not called.
all things in the scene have colliders.

I would be grateful if you could tell me what's wrong

edited: it works if either the sphere or the other object's collider is trigger and I use onTriggerEnter.


texts: How to restart the timer after using deltaTIme

texts:
I am creating a simple game interface. When fillAmount > 0, the timer is stopped and reset. I want to restart the timer if the fill amount does not change for 3 seconds. All the code does now is counting 3 seconds and then displaying the time when it stops. How do I fix it?
private float startTime;
private float reStartTime;
public Barscript barscripts;

void Start() {
    startTime = Time.time
    DefaultImg = GetComponent<Image>();
}

void Update() {
    float t = Time.time - startTime;
    reStartTime = 3;
    float t1 = reStartTime - startTime;

    string hours = ((int) t / 6).ToString();
    string minutes = ((t % 6) * 10).ToString();

    Debug.Log(barscripts.fillAmount);

    if (batscripts.fillAmount > 0) {
        DefaultImg.sprite = Emoji3;
        startTime += Time.deltatime;
        timerText.text = " 0   :   00 "
        Debug.Log(t1);

        if (t1 < 0) {
            timerText.text = hours + "   :   " + minutes;
        }
    }
}

Here's a sample image of what I'm getting at the moment.


texts: When using MVC, what is the proper way to handle a view refresh when the model isn't ready?

texts: I'm about to start building a game and am having trouble understanding the proper course of action when it's time to refresh the screen, but the model hasn't finished its calculations. I assume this isn't a huge problem for my little 2d platformer, but with many complex games there must be some hefty calculations that don't render in 1/30th of a second - I see these games stutter, but what's going on? Is the view just skipping this cycle? Is it an observer that's waiting for the model and will hang until the model is ready? Or will it display the models current state without regard to the computations ongoing? What's the correct way to handle this situation?


texts:
Take a look at this picture:

This is a picture of me diving down from a high height. As you can see, the world is a simple world with grass, snow, trees, etc.

The problem here is the 3D foliage. If is obviously just "jumping" into the scene. It also changes the scene dramatically - Instead of simply adding detail to the "current" scene, it's effectively overwriting the terrain underneath it and setting it's own colours/details.

Let's take a look at a popular game, such as war thunder:

Yes, you can see the 3D foliage appearing as the player gets closer to it. However, it is very hard to actually focus on how or where it is appearing. Also, the grass adds detail to the terrain, rather than completely overwriting it and providing a completely different picture.

The TL;DR on this is - My game has grass that "pops" into existence and creates an obvious change in the terrain, whereas professional games have unobtrusive hard-to-notice geometry gradually fading into view.

How do other games do this, and how can I implement it?


texts:
I have a script to edit my world on run time and a script to generate a world. When i tried to place a block, something wrong happened, so I tried to make my script into command until I find which line was wrong. However, my comments still seem to execute. I made all the lines of update into comments, I still detect my mouse click, and it is the only script to use mouse click.
Infos:
-using IEnumerator to generate world.
-using /.../ for comments
-if I try to put a Debug.Log("..."); in the comment part, it doesnt show up in the console, which is even weirder.


texts: Unity3d Rigidbodies overlap even at low speeds

texts:
I have an issue that I can't solve. There are many questions relating to similar issues and they come down to "change some settings" and "object is travelling too fast". My problem doesn't seem to equate to either of these.

I am running through the basic tutorial for the Breakout Game and have added some of my own tweaks to the code, my issue is that even at low speed my ball overlaps with the bricks, rather than bouncing off them.

I have read various related questions but nothing seems to fix this for me.

Things I've done:

Set Project Settings >> Physics2d >> Maximum penetration For Overlap = 0.0001
Set Ball RigidBody Collision detection to "Continuous Dynamic" .
Set Brick RigidBody Collision Detection to "Continuous"
Forced a speed limit on the ball of 25 15. Which I think is not fast at all, as most the given solutions are talking about situations arising when the offending object is travelling at much higher speeds.
Bricks are standard rigidbody cubes and ball is a standard rigidbody sphere.
According to this answer I have also set the rigidbody interpolation to "interpolation" for both ball and bricks. But this seems processor expensive and doesn't solve the issue.
As well as set the Project Settings >> Physics >> Solver Iteration Count to 25. This does seem to have helped somewhat (ball no longer gets "stuck" inside brick wireframes, but still overlaps).

Below are some screenshots of my issue and my code.

The only aspect that I can't fully account for is that I've added an acceleration function so when ball is launched it accelerates over a course of several seconds to it's max speed. It's start speed is 8 (although the force applied is actually 1000 when launched, ignore that figure), and the max speed is set to 25 15. I don't know enough to say if this is somehow "breaking" rigidbody overlap detection but it seems pretty silly if so. See line 63 below:

Ball Source Code:

using UnityEngine;
using System.Collections;

public class Ball : MonoBehaviour {

    public float initialVelocity = 500f;
    public float accelerationSpeed = 5f;
    public float MaximumSpeed = 15f;
    private Rigidbody rb;
    private bool ballInPlay = false;

    void Awake () {
        rb = gameObject.GetComponent<Rigidbody>();
    }

    void Update () {
        if (Input.GetButtonDown("Fire1") && ballInPlay == false)
        {
            transform.parent = null;
            rb.isKinematic = false;
            rb.AddForce(new Vector3(initialVelocity,initialVelocity,0));
            ballInPlay = true;
        }
    }

    void FixedUpdate ()
    {
        /***
         * Gradually increase ball speed
         ***/
        if (ballInPlay == true && rb.velocity.magnitude < MaximumSpeed)
        {
            speedUp();
            Debug.Log("Ball Speed is "+rb.velocity.magnitude);
        }

        /***
         Clamp to maximum speed
         ***/
        if (ballInPlay == true && rb.velocity.magnitude > MaximumSpeed)
        {
            rb.velocity = rb.velocity.normalized * MaximumSpeed;
        }

    }

   //     rb.velocity.magnitude

    void speedUp()
    {
        /***
         This is line 63:
         ***/
        rb.AddForce(rb.velocity.normalized * accelerationSpeed,ForceMode.Acceleration);
    }

}

Why are the rigidbodies not detecting and preventing overlap?


texts: When should you roll your own game engine?

texts:
I've been a software developer for 5 years, now, and I am wanting to get into iOS game development. I've played around with the iOS SDK for about 2 years, attending cocoaheads meetings, and I feel I have a good grasp on objective-c, cocoa and even c and c++.

I have a game idea, and know that I will use Box2D, but I'm wondering if I should use cocos2D or not. The main reasons are:

I may want to do things, graphics wise, that aren't available in cocos2d.
If I roll my own game engine, I'll have more control.

Of course, the main reason for using an already-existing game engine is the time it saves, and it makes the hard stuff easier; but for someone who has the technical chops to roll his own, does it make sense?


texts: How does QCSAA actually work in nVidia GPUs?

texts:
I know the principles behind how QCSAA is supposed to work (as opposed to how, say, regular CSAA works) and subjectively after some testing I like the style it lends to the image enough that I'm considering turning it on by default in certain situations. The question is - I've read that in practice it doesn't work quite as described. Theoretically, it should only be considering coverage samples from the the nearest edges of neighboring pixels along with the local pixel's samples in its calculation, which makes sense. But I've seen it claimed that it's actually just a blur filter over an antialiased image - that is, a 8xQCSAA frame is just rendered using 8xCSAA and then slightly blurred, using the finished pixels as samples.

This is obviously not the same thing. Does anyone know how it works for sure?


texts:
I'm working at making a HTML5 game. Top down, closest thing I can equate it to is the gameboy zeldas, but open world and no rooms.

What I have so far is a procedurally generated map in a multi dimensional array. And a starting position on the map. Along with this I have an array of movable and non movable tile ID's.

I also have a class for my player and have him being rendered out in the center of the starting tile.

My problem however is getting the movement sorted out for the player. I want to be able to have the character free move around the map (pixel by pixel essentially) ontop of this 2D generated world. Ideally this would allow the user to move around the walk able area of the canvas. this is simple enough for me to do, but I am having problems now moving the world.

If the user is 20% from the edge of the screen i want the world to start panning in the direction the player is heading. But I'm rather lacking in ideas of how to do this.

I've looked around for some tutorials, but am coming up blank on ideas of how to generate the playable area (zoomed in) and to then move this generated area under the player when they reach near the end of the screen.

My current idea was to generate a certain amount of tiles full size to fill the screen and place the player i the middle. Then when the user approaches the edge of the screen start generating the tiles offset by the distance moved and the direction. I can kind of see this working but I really have no idea if this is the best or easiest to code of methods for generating the world.

sorry for the lack of code but I'm still just in the theory stages of working this all out.


texts:
I am currently working on a terminal text game just to practice my skills (C). It will be story driven escape the mansion kind of game. Even though the game will be short I want it to support save files.

Since I am new to game programming I am not sure how should I handle save files. The game will be short yet players will be able to find a lot of objects. I was thinking about saving a structure into a .txt file OR saving lots of 1 and 0 into txt file. Where each line represents each item or progress.

Is there a better way or common way how to do it?


texts: How do you implement 2D collision detection?

texts:
I would like to know the best or most efficient way to test for 2D collision.

I am currently using AABBs, but the problem with this, is that your objects will be hitting things when they shouldn't. On top of this, AABBs cannot be rotated.

I was considering using per pixel collision, but I feel that it would lag on large bitmaps, since there would be a lot of pixels to check.

What I would like to know, is how I can allow my bounding boxes to be rotated, and use any polygon instead of just rectangles for collision. Also, is there a way of creating circular collision bounds that aren't just approximations of circles?


texts: Out of screen position to inner screen position

texts:
I don't know how I could solve this.
I'm trying to accomplish this:

 So if a object is out of my screen I would like to calculate the position it would be inside of the screen. Searched already but did not found any help for this problem. You can see this in games like cod where it shows you from which direction you got hit by a bullet.

Thanks in advance.