texts: Get the position of a GUI.Button and instantiate in its position

texts:
I am trying to instantiate a GUI.Box in the position of my GUI.Button when it is clicked but I just cant seem to get the position of the button. The button does change position.

Here is the code of my button in my Editor script:

void OnGUI () {
     GUI.Button(new Rect (5,95, 300, 100), "Hello");
}


texts: How can I divide a grid map into clusters for path finding algorithm?

texts: I am trying to implement HPA algorithm for finding the shortest path between two point. I came across the paper Near Optimal Path Finding Algorithm (by Botea, Müller & Schaeffer) but I am stuck at the clustering part. I have a 2 dimensional array and each index in the array is a node. Could anyone help me clustering my 2 dimensional array into clusters?


texts: Is there a javascript physics engine that does not require canvas?

texts:
I just need a really simple and small physics engine for squares or circles that moves images using javascript. For the project that I am working on, I can't use canvas, so I will be moving the images via the dom. If I understand it correctly, Box2D and PhysicsJS both require the canvas (or at least in my testing that seemed to be the case). I don't really want to make my own, because I bet there is something out there that already does this.

So, is there a javascript physics engine that does not require canvas?


texts: So now that the restrictions are lifted from the third party developer by Apple. And the new packager for iPhone for Flash in CS5 is available for download. How much efficient it can be to develop a game in Flash for iPhone. How much worth it can be to invest time in developing games on Flash? anybody started working on game development on Flash for iPhone can help a lot.


texts: Small health bar above entity is drawn differently when the entity is rotated differently

texts:
Here is a simple positioning code for my health bar:

transform.position = Camera.main.WorldToScreenPoint(target.position - 0.2f * target.up);

Here is the prefab:

HealthBar is middle-center anchored, and 0.5, 0.5 pivoted,
Background and Fill are stretched and 0.5, 0.5 pivoted, but background is Left, Right, Top, Bottom -1 positioned.

Here is how it should look: (all images are zoomed in)

And here is a video about the entity rotating around: https://i.imgur.com/EOzFEvt.mp4

2 example rotations, in which the health bar is drawn incorrectly: (see the border of the bar)

Why?

Edit: Another interesting artifact:

If I'm moving the camera up, the healthbars are offsetted up a bit, and if I start moving down, it's instantly offsetted down, with left and right the same, etc. As soon as I stop, it's at the correct position, but as soon as I start moving, it becomes offsetted to the direction I'm moving.

See gif: https://i.imgur.com/K8mwzTW.mp4

Fix for this: Place it in LateUpdate.


texts: A single libgdx gamescreen with pop-up menu, getting ready, hud and game over?

texts:
Is it possible and practical to have only one screen, like a GameScreen class, where the menu, getting ready (plus instructions), hud (only score) and game-over screens can pop-up when needed. Can I do this with the Table class from libGDX?

I'm asking this because I am working on a game where I would like to have the game-world in the background of the menu for game over etc. It's a 2D side-scrolling game, something like Flappy Bird or Swing Copters. I don't need the menu to be on a completely different screen! :D


texts:
Unity shows only admob test ads. I changed adunitId device id and removed test device but it still shows test ads real ads not shown. Please help me about the problem.

Thank you


texts: Can't detect collision properly using Rectangle.Intersects()

texts:
I'm using a single sprite sheet image as the main texture for my breakout game. The image is this:

My code is a little confusing, since I'm creating two elements from the same Texture using a Point, to represent the element size and its position on the sheet, a Vector, to represent its position on the viewport and a Rectangle that represents the element itself.

Texture2D sheet;

Point paddleSize = new Point(112, 24);
Point paddleSheetPosition = new Point(0, 240);
Vector2 paddleViewportPosition;
Rectangle paddleRectangle;

Point ballSize = new Point(24, 24);
Point ballSheetPosition = new Point(160, 240);
Vector2 ballViewportPosition;
Rectangle ballRectangle;
Vector2 ballVelocity;

My initialization is a little confusing as well, but it works as expected:

paddleViewportPosition = new Vector2((GraphicsDevice.Viewport.Bounds.Width - paddleSize.X) / 2, GraphicsDevice.Viewport.Bounds.Height - (paddleSize.Y * 2));
            paddleRectangle = new Rectangle(paddleSheetPosition.X, paddleSheetPosition.Y, paddleSize.X, paddleSize.Y);

Random random = new Random();
ballViewportPosition = new Vector2(random.Next(GraphicsDevice.Viewport.Bounds.Width), random.Next(GraphicsDevice.Viewport.Bounds.Top, GraphicsDevice.Viewport.Bounds.Height / 2));
ballRectangle = new Rectangle(ballSheetPosition.X, ballSheetPosition.Y, ballSize.X, ballSize.Y);
ballVelocity = new Vector2(3f, 3f);

The problem is I can't detect the collision properly, using this code:

if(ballRectangle.Intersects(paddleRectangle))
{
    ballVelocity.Y = -ballVelocity.Y;
}

What am I doing wrong?


texts: Is this an appropriate use of abstraction in my game engine?

texts:
I have been stuck in the design phase on my new game for a few weeks now because I keep finding new parts of the game engine that I could make more modular and neat.  I did, however, run into a problem recently where I found that a seemingly logical modularization lead to some (what I thought to be) bad practices. Let me explain:

The Situation

I am writing a game that has a series of physics objects, called Bead's that move around within the closed walls of the screen.  Now, The Bead object contains all the necessary information that a Bead needs, however I recently removed the velocity and location information out and into a PhysicsObject class, as I figured if I ever wanted to introduce more shapes, I could reuse this code (a good practice, right?).

I then moved another part of the Bead out of the Bead class: the region bounding the drawn bitmap.  This would allow me to create other regions in on the board that could react to touch input from the user (considering it is an Android game).  I made this an interface (since you can only extend from one class at a time in Java), called Boundable, and had the Bead class inherit the traits from that class.

Note that one of the main reasons I pulled out this information because I wanted the Board object to also inherit these traits (because their bounding information is very similar) that would allow me to bound the screen and work with object collision in a much more object-oriented manner.

The Problem

Since the interface contains information related to the bounds of an object, and since it must be an interface, then the access modifiers must be public either public, static or final, and I would prefer them to be protected.  I don't want the location information of the objects in my game to be publicly available as it could permit some malicious program the ability to change the values.  Am I correct in this assumption?  Am I just going about this in the completely wrong way?  Perhaps being too picky?  Please let me know if you need any additional clarification.

Any help would be greatly appreciated.

Here is the code for those of you that would prefer to see what I'm doing first hand:

Boundable.java

public interface Boundable{

    //I would like these values to be protected.
    public float left;
    public float right;
    public float top;
    public float bottom;

    public boolean contains(float x, float y){}
}

UML Diagram

You may find a UML diagram of the setup I currently have, here.


texts:
I m in need of some UX guidance if there is any for a game in mobile.

for example for pausing the game (assume I m not using iOS) say you want to pause the game and you dont want to loose part of the screen on having a button that will pause. I was thinking of using some sort of gesture ( double tap?, slide up?) is there any default standard?

Cheers


texts: Different shaders for different objects DirectX 11

texts:
I am learning Direct3D 11, and in all basic tutorials I found on shader writing, Vertex and Pixel shaders are written so they transform whole scene same way. Tutorials like render cube with texture...

But I wonder, how do you differentiate objects? What if you want, for example, to simulate mirror surface on some object and use different shaders to render rest of the scene? I think that most games must use many vertex and pixel shaders to achieve various look and transformations.

Thank you.


texts: How should I be loading a player's content and its bullets content later in the game

texts:
I'm trying out Monogame because my course has a simple game programming class in it which is just going over basics. The final project will be using Monogame so I've been getting ahead and making my game.

Anyway, each player (Tank) has a list of Shells (bullets) and a list of Tracks (tank tracks). I load their content in the player's LoadContent method. LoadContent is called when the game is ran.

Let's say I wanted to add a new player sometime later in the game for whatever odd reason. I would do something along the lines of:

 entityManager.Add(new Player("Player Name", resourceManager.GetTexture("BlueTank"))
 {
      set initial position and keybinds here,
 };

This successfully creates a new player and loads its texture but what about its bullets textures, sound effects, track textures etc... Since LoadContent only gets called once at the start the code below will not run.

Example of the player's LoadContent method:

 // Match the players bullets with the players colour
 switch (Texture.Tag)
 {
      case "BlueTank":
           shellTexture = resourceManager.GetTexture("BlueShell");
           break;
      case "DarkTank":
           shellTexture = resourceManager.GetTexture("DarkShell");
           break;
 }

 // After this I use the resourceManager to set private Texture2D's and sound effects for the bullets, tracks and player.

 // e.g.
 trackTexture = resourceManager.GetTexture("Track");

When I finally shoot a bullet I set the bullets texture and sound effect properties to the private ones in the player.

When a player dies I currently just set their IsActive bool to false and the entity manager will remove them completely so I'm stuck on how to load content again.

I feel like I'm overthinking this but I can't seem to find a clean and simple way to get this done. Also I'm bad at explaining things hopefully this isn't too much of a mess.

Edit: Would it be a bad idea to pass the resource manager in the players constructor and just create a method for loading that is called in the players constructor? That way when a player is created the content is loaded for that player. It's only a small game for a basic school project. I could potentially do all the content setting outside of the player itself and in the GameplayState by looping through unloaded entities or something.


texts: How do I fix a delay between the first and second KeyEvent

texts:
I recently got really interested in making my own little game. As I have no real game development background I'm still figuring stuff out, but I encountered a little problem.

While working on the user input, I noticed a delay between the first and the second time the key event gets called.

Can somebody give me a tip on how I can fix it? I already had a method to make the changing a bit slower. But the input delay kinda broke the method.

Here you can see the problem https://gfycat.com/EvenCreepyAsianconstablebutterfly

As you can see from the console output I have a delay before the second activation.

    run_anim = new Image[4];
    try {
        sprite_idle = ImageIO.read(new File("img/sprite/base_.png"));
        run_anim[0] = ImageIO.read(new File("img/sprite/run_0.png"));
        run_anim[1] = ImageIO.read(new File("img/sprite/run_1.png"));
        run_anim[2] = ImageIO.read(new File("img/sprite/run_2.png"));
        run_anim[3] = ImageIO.read(new File("img/sprite/run_3.png"));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    spriteInx = run_anim.length;

    currentImage = sprite_idle;

Here is my key event:

public void keyPressed(KeyEvent e){
    int key = e.getKeyCode();

    for(int i = 0; i < handler.object.size(); i++){
        Entity temp  = handler.object.get(i);

        if(temp.getID() == ID.Player){
            //Player Control
            if(key == KeyEvent.VK_LEFT){
                System.out.println(System.currentTimeMillis());
                Player tempP = (Player) temp;
                tempP.startRun("left");
            }
            if(key == KeyEvent.VK_RIGHT) temp.setVelX(2);
        }
    }
}

I add my images in the constructor of the player

And here you get the code for my startRun method.

public void startRun(String string) {
    running = true;
    if(string.equals("left")){
        nextSprite(string);
    }

}

public void nextSprite(String dir) {
    if(running){
        if(dir.equals("left")){
                if(spriteCount < spriteInx-1){
                    currentImage = run_anim[spriteCount];
                    spriteCount++;
                }else{
                    spriteCount = 0;
                }

                currentImage = run_anim[spriteCount];
                setVelX(-2);
            }
        }
    else{
        currentImage = sprite_idle;
    }
}

If you need anything further, just tell me.

I use AWT and Swing and nothing like lwjgl or jmonkeyengine.


texts: Finding other programmers to help on a project

texts:
As a semi FAQ question attempt :

Where can you find people to work with you on a project? Particularly programmers. One thing that is obvious is that all programmers have a project (or twenty), and the chances of a programmer just hanging around looking for something to do is a lot less likely than if it were an artist needed on the team.

So, where do you post? Where do you search and follow people around until it looks like they are a viable team member? Is it really difficult to assemble a team that are not close friends or chat buddies? Are there sites with this sort of posting?

To clarify : I am referring to a team.

Example 1 : I am making gameEngineOfAwesomeness. I need help.

Example 2 : I am 70% complete on this game, and i need help.

Example 3 : I have an open source project idea, with a prototype. I need help.

It doesn't necessarily mean open source, just programmers who can work with me on something (and where to find them :))


texts: Unity OnControllerColliderHit triggered multiple times in one frame

texts:
private void Update()
{
     Debug.Log("### " + CollisionFlags);
     CollisionFlags = CharacterController.Move(moveAmount);
}

private void OnControllerColliderHit(ControllerColliderHit hit)
{
    Debug.Log("### OnControllerColliderHit " + hit.gameObject.name);
}

the characterController is heading down to plane and
I called characterController move function in update() and i expect the result is like
"None"
"OnControllerColliderHit Cube (2)"
"Below"
"OnControllerColliderHit Cube (2)"
but result is
"None"
"OnControllerColliderHit Cube (2)"
"OnControllerColliderHit Cube (2)"
"OnControllerColliderHit Cube (2)"
"OnControllerColliderHit Cube (2)"
... 12 times.
"Below"
Why OnControllerColliderHit triggered 12 times in one frame?


texts: How do i make floors of varying height in OpenGL?

texts:
So I am currently working on a small Game(/engine) in OpenGL and I want to build a little world editor. Nothing too fancy: Just some functions to add objects to a scene and manipulate them (rotation, translation etc). Up to now I have everything set up for loading models into the scene and setting up simple directional- and pointlights.

But one thing has been bugging me since the start: What is an average floor / ground made out of? I would guess that, for exmaple, a grass floor is just a lot of vertices / faces with a grass texture wrapped on them. But how are those textures connected and how can you change the elevation for certain vertices to create hills?

I am essentially asking how the recommended implementation of floors is in 3D environments (preferrably OpenGL 3.3) since I can't find anything on that topic on Gergl.


texts:
So a friend of mine and myself are starting to create our first game together.
We descided on doing a 2.5D kind of game, so a static camera that moves with the player but cannot rotate.

I got the collisions object from my friend which in unity looks like this:

Now I'd like to create an overlay with a JPG image which is going to cover the entire viewport and is going to "be" the map itself. I want to use this JPG as a kind of background image and then hide the collisions so the player will walk into the collisions and stop there but can't actually see them. In stead, he will see the image with buildings on it.

How can I do this correctly?
I've gotten as far as creating a second camera which will show me the image and then trying to create an Image (Create gameobject -> UI -> Image).

But I cannot find any way to continue on this.

Is this a good way to do this whole 2.5D kind of thing?

We want lightweight maps in our game and thought this was a good idea to go about this.

Edit

My friend and me are trying to create an isometric game like this.
The reason behind this is that the amount of work for the map is going to be massively reduced if we can do it like this since he can then just work in photoshop, in which he's super good.

This was he does not have to bother with the 3d design in detail and can make the collision blocks much faster.

So does anyone know how to get this to work? Maybe someone has a partial guide on this because I cannot seem to find anyone doing it like this but I imagine that ie Commandos is made like this.

It would be much appreciated!


texts: OnClick events - using Scaleform UI with Cryengine 3.5.4

texts:
I've created a UI in Flash, set up an xml file for it and designed a flowgraph to ensure it displays when I launch. However, clicking on the buttons doesn't appear to do anything, despite me writing a click event in AS, linking to it in the xml, and connecting the function to a level change in the flowgraph.

XML:

<UIElements name="zlogicGUI2">

<UIElement name="GuiV2" render_lockless="1">

<Gfx file="GuiV2.gfx" layer="0">
<Constraints>
<Align mode="dynamic" valign="center" halign="center" scale="0" max="0" />
</Constraints>
</Gfx>

<events>
<event name="OnClick" ExternalInterface="ButtonClickPressed" desc="" />
</events>

</UIElement>

</UIElements>

ActionScript 3 (created in Flash CC)

button_1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

function fl_MouseClickHandler(event:MouseEvent):void
{
    ExternalInterface("ButtonClickPressed");
}


texts: What platform should I use for a master server?

texts:
We are making a small FPS, and want people to be able to play it online and fetch a list of all servers from a master server. We only have experience in C#, and we have already written a master server that tracks all the servers.

However we realize that we'd have to host it on a windows application server. These are expensive, and making our master server completely reliable and watertight may be a lot of work. Also it seems a waste to have a server out there running windows and our tiny application that only tracks a list of servers...

Should we make the effort to learn PHP and SQL and make our master server that way? Does anyone know of any master servers written in PHP to get us started?


texts:
I have a texture and I want to "colorize" it with a given color, lets say cyan (#00ffff) or purple (#800080). What I want to do, is get all the pixel values from the texture, and remove the color and keep the "brightness" and "saturation" and apply to the desired color. There is a tool in GIMP to do this called Colorize (Colors -> Colorize.. while editing), I made an example below.

This is will all be done in a shader (GLSL), although this is probably a general algorithm.


texts: How does 3D games work so fluent provided that each mesh's size is so big?

texts:
I'm surprised to find that each mesh takes at least 5-6 MB,

how can a 3D game be so fluent when there are hundreds of models?

I'm expecting it will simply go out of memory or something else that makes the game un-playable..

What's the trick employed here?


texts: How to mitigate this strange pattern shown in Phong lighting?

texts:
I am creating an entire lighting scene in OpenGL. The entire scene consist of only one point light. I noticed some strange z-fighting like pattern. This flickers when I move the camera.

Can anyone tell me what is the potential cause of the problem? How should I mitigate this problem? Thank you.

===

EDIT: The problem is solved. It was primarily caused by normal transform computation error and my ill made model might have been aggravated this speckle flickering effect.


texts:
I rotate my game character to watch at the target using the following code:

        transform.rotation = Quaternion.Slerp(startQuaternion, lookQuaternion, turningNormalizer*turningSpeed/10f)

startQuaternion is the character's current rotation when a new target is given.

lookQuaternion is the direction the character should look at and it's set like this:

    destinationVector = currentWaypoint.transform.position - transform.position;
    lookQuaternion = Quaternion.LookRotation(destinationVector, Vector3.up);

turningNormalizer is just Time.deltaTime incremented and turningSpeed is a static value given in the editor.

The problem is that while the character turns as it should most of the time, it has problems when it has to do close to 180 degrees. Then it at times jitters and mirrors the rotation:

In this poorly drawn image the character(on the right) starts to turn towards the circle on the left. Instead of just turning either through left or right it starts this "mirror dance":

It starts to rotate towards the new facing
Then it suddenly snaps to the same angle but on other side and keeps rotating

It does this "mirroring" so long until it looks at the target. Is this a thing with quaternions, slerping/lerping or something else?

EDIT1:
Apparently the issue does not arise from the rotating itself. The more likely issue is that the character moves toward the facing while it rotates. As limiting the angle, between facing and target, when the character is allowed to move reduces and at times eliminates the jittering/mirroring rotation.

This of course raises more questions, why cannot the character move and rotate at the same time without issues? Code used for the movement:

transform.Translate(Vector3.forward * runningSpeed/10f * Time.deltaTime);


texts: Is it possible to reverse perspective projection with simple scale and translate?

texts:
Basically I'm asking this question (which seems to have gone un-answered): How to do perspective projection “parallax” but without changing the scale or offset of objects?

I'm using perspective projection and would like to scale up certain objects in the background (z < 0) such that they would render unscaled and in the same relative position. In other words, I want to reverse the perspective foreshortening for bg objects.

I've figured out how to unscale accurately: basically I project the top left and bottom right corners of the image to z = 0, then do the same at the current z value. I then compare the change in distance between the points in order to derive the scale factor.

The problem I have though is once I unscale the object, its position is incorrect. I've tried scaling around different anchor points, with no luck. I can't seem to derive a generic formula to position the images in the correct places after scaling.

Any ideas how to do this? Is this even mathematically possible?


texts: What does the keyword "interface" mean in GLSL?

texts:
interface vs_out
{
  vec3 get_color();
};

struct vs_out_impl : vs_out
{
  vec3 get_color()
  {

    return vec3(1,0,0);
  }
}

Where is this behavior defined? None of the specifications uses the keyword interface. It is generally reserved in version 460. I myself accidentally, at Visual Studio, discovered that this keyword is recognized, thought about it and remembered the Nvidia language C for graphics. It has the ability to create interfaces. I tried it and it worked! This code does not crash with compilation errors. It compiles fine. To check, instead of the diffuse color, I used the method vs_out_impl::get_color(), and the objects were painted red.

Where to see the specification of this functionality? On the Internet, a bunch of words interface and GLSL leads to articles on interface blocks, which is not the same.


texts: Building dynamic bounding box hierachies

texts:
I've been reading about collision detection and I saw that the first part was a coarse detection which generates possible contacts using bounding box hierarchies.

I understand the concept of splitting up your objects in groups, to speed up the detection phase, but I'm a little confused on how do you actually build the hierachy, more so on what criteria is used to group them together.

Do I iterate through all the objects in the scene, and check the distance between them to see where they should be inserted in the tree?

Do you know some resources that may shed some light on this topic for me?


texts: How to make an object covers a specific distance before moving in other direction for same distance?

texts:
Suppose there is a small tile and I want an object to move on x axis on that tile back and forth.
How can I make that object in that specific tile.
My code is :
 Rigidbody2D rb;
// Start is called before the first frame update
void Start()
{
    rb = GetComponent<Rigidbody2D>();
}

// Update is called once per frame
void Update()
{
    rb.velocity = new Vector2(-3f, 0);
}

As of now object moves left but I want it to start moving right and not go of the tile.


texts: How to visually "connect" skybox edges with terrain model

texts:
I'm working on a simple airplane game where I use skybox cube rendered using disabled depth test.
Very close to the bottom side of the skybox is my terrain model.

What bothers me is that the terrain is not connected to the skybox bottom. This is not visible while the plane flies low, but as it gets some altitude, the terrain looks smaller because of the perspective. Since the skybox center is always same as the camera position, the skybox moves with the plane, but the terrain goes into the distance.

Ok, I think you understand the problem. My question is how to fix it.
It's an airplane game so limiting max altitude is not possible. I thought about some way to stretch terrain to always cover whole bottom side of the skybox cube, but that doesn't feel right and I don't even know how would I calculate new terrain dimensions every frame.

Here are some screenshot of games where you can clearly see the problem:
(oops, I cannot post images yet)

darker brown is the skybox bottom here: http://i.stack.imgur.com/iMsAf.png
untextured brown is the skybox bottom here: http://i.stack.imgur.com/9oZr7.png


texts: extrapolating object state based on updates

texts:
I have a networked multi-user collaborative application. To maintain a consistent virtual world, I send updates for objects from a master peer to a guest peer. The update state contains

x,y,z  coordinates of object center and his rotation matrix(CHAI3d api used a 3x3 matrix) with 30Hz frequency.

I want to reduce this update rate and want to send with a reduced update rate. I want a predictor on both peers. When the predicted value is outside, say a error value of 10% in comparison to  master peers objects original state the master peer triggers a state update.

Now for position I used velocity,position updates so that the guest peer can extrapolate position.

Like velocity for position what parameter should I use for rotation extrapolition?


texts: How do games go about designing weapon damage?

texts: In Action-RPG games, I was wondering how weapon damage numbers  and attack speeds are decided on. Do most games come up with their own or do they "steal" numbers from other games? How would I go about coming up with my own numbers?


texts:
I have my collision detection code working so how would I tell my HealthPickup to disappear when my Player collides with it? I haven't played around with it yet but I think I may have to somehow remove the hitbox and stop calling the Draw() function (at least for my HealthPickup anyway)

Please note I am a novice and have not really dealt with XNA before.


texts:
Hello, I want to twist the plane. The plane looks like this when I try to do it the way I linked below.
How can I my plane roll like photos?
How can I roll up a plane with a vertex shader?
you can see DMGregory answer in this link. I create new shader and paste this code. When I put my mat. to plane. It looks like this.
(Sorry for my bad english.)


texts: Unity & Alternatives to non-convex collider + non-kinematic rigidbody

texts:
I am working on a voxel game, where everything is one or more chunks of voxels (16x16x16).
As voxels can be destroyed the chunk and collision area changes and can of course become non convex.
So to get collisions I put a non convex mesh collider on the chunk.
This is fine and works for my terrain as there is no rigidbody on the object.

Now my player object also consists of chunks of voxels, and everything which applies to my landscape, also applies to my player object (destroyable, needs non convex collider), but I also want my player object to be driven by physics, collisions resolved by physics and so on.
So it needs a rigidbody.

But Unity5 doesn't allow non-convex collider with non-kinematic rigidbodies.
So what are my options?

My requirements again: Everything driven by physics + collisions with destroyable non convex geometry...


texts:
If  there are 2 GPUs in a PC, one processing only graphics and the other dedicated to PhysX, what is the flow of the physics-related data?

Let's say we're simulating an explosion and the PhysX calculates exploded elements (position, size, number, whatnot) while graphics GPU renders them. Does CPU send input to PhysX GPU, gets the results and sends (some of) them to graphics GPU? Or is something like this possible: CPU sends input data to PhysX GPU and, after performing calculations, data from PhysX GPU goes straight to graphics GPU (omitting CPU altogether) since they're just used to render stuff anyway and CPU doesn't need to do anything with them?

Edit: Actually, as a bonus question, I'd like to know the same in case of just one GPU (used for both PhysX and graphics). Does the data flow to GPU, gets calculated, returns to CPU and then goes back to GPU for rendering or can it "stay" on GPU?


texts:
I am currently implementing a 2D skeleton system in C# with XNA, but got stuck in how I would rotate the bones around a skeleton's axis.

A basic algorithm that I have figured out already would involve, one part or another, manipulating the coordenates of the bone around the axis. I just cannot find the equation that would return these coordenates once provided an angle.

For example, if the bone's axis.X originally is -1 and its axis.Y -2 units away from the skeleton's axis' X and Y, then when the skeleton is rotated 90 degrees the X difference would become 2 and the Y, -1 (illustrated).

I'm certain the function I'm looking for would end something like this:

    void rotateVector (Vector2 vectorToAnalyze, Vector2 axis, float currentAngle, float newAngle, out Vector2 result);

If there are already functions that do the job, then I wouldn't mind using them - I'm certain there's something in the Matrix class related to this, but I'm a bit overwhelmed by it. As much it really would be nice to learn how this whole deal rolls, the most important thing to me, simply, is to find a solution that works this way I intend.


texts: How to request a specific OpenGL version?

texts:
I'm working on an OpenGL project, coming from D3D. They're organised in very different ways, so it's tricky going :)

Is there any way for a Windows application to request a specific OpenGL context version, e.g. 2.1 or 3.x?

Also, I believe I need to use wglext.h from the OpenGL registry as the GL.h that ships with Windows is an earlier version, 1.1 or 1.4 - can anyone confirm?


texts: How to play a video with audio using an image marker

texts:
I want to play a video with audio using an image marker. In other words, user scans image marker with phone and a video with audio plays.
I am finding plenty with vuforia but how can I do this with AR Foundation?


texts:
I have started to develop a simple 3D engine. I use OpenGL for rendering, and it is developed for Windows. It is all written in C.

How do I write an interface for the keyboard and mouse input? I would like to keep it as simple as possible - in contrast to the native Win32 input system.


texts: Can I use unlicensed art to develop and raise money for my game?

texts:
I've been developing a prototype for a game that has been made with art that I have neither paid for or asked for permission to use. Naturally once I move towards selling or distributing my ad-supported game, I'll need to replace the art with its licensed equivalent, or pay for my own.

This is generally how game engines work, with you using an unlicensed copy until you release and start to make money off of it, so I thought maybe it would be the same in the game art world.

Can I legally develop and say, start a kickstarter, using a game with unlicensed art?


texts: Why don't beat 'em ups allow player character sprites to face toward or away from the screen?

texts:
Most beat 'em up games don't allow player character sprites to face away or towards the screen. For example, in Streets of Rage, when you press up, the character moves up, but it is still facing either left or right, and the same is true when you press down.
Even in modern beat 'em ups, this is the case. What is the reason for this? I used to think this is because the graphics are 2D, so it's harder or more work to get characters to face towards or away from the screen. But even in beat 'em ups that use 3D graphics, this is still the case, like Double Dragon Neon.


texts:
I'm writing an application which renders graphics on the screen. The application can switch between Direct3D9 and Direct3D10 graphics modules (I wrote DLLs that wrap both D3D9 and D3D10). When trying to render a test mesh (a torus which comes as a stock mesh in D3DX9 and in DXUT library you can find in DirectX10 samples), Direct3D10 module behaves rather weird. Here's what I get.
D3D9:

D3D10:

The view, projection and world matrices are the same for both cases. The only thing that differs is the device initialization code, and the HLSL effect files (for simplicity I only apply ambient colors and don't use advanced lighting, texturing etc). Can this be because of wrong device initialization or because of bad shaders? I would appreciate any hint. I can post any code pieces by request.
Thanks in advance.


texts: libGDX Error loading font file - Netbeans

texts:
I'm trying to load a font in libGDX. But I can't figure out want I do wrong.

Code:

white = new BitmapFont(Gdx.files.internal("fonts/white.font"), false);

Error:

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Error loading font file: fonts/white.font
    at com.badlogic.gdx.graphics.g2d.BitmapFont$BitmapFontData.load(BitmapFont.java:657)
    at com.badlogic.gdx.graphics.g2d.BitmapFont$BitmapFontData.<init>(BitmapFont.java:469)
    at com.badlogic.gdx.graphics.g2d.BitmapFont.<init>(BitmapFont.java:115)
    at scenes.GameMode.create(GameMode.java:61)
    at scenes.GameMode.<init>(GameMode.java:45)
    at com.circle.game.Circle.create(Circle.java:17)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:143)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.substring(String.java:1931)
    at com.badlogic.gdx.graphics.g2d.BitmapFont$BitmapFontData.load(BitmapFont.java:480)
    ... 7 more
:desktop:run


texts: Unity Generating PolygonCollider from mesh

texts:
I generated a procedural mesh using marching squares and the MeshFilter component (it's 2 dimensional). Now I got the point that I need do collision detection with the character (a sprite with a box collider).

I tried simply converting the mesh's vertices to Vector2s and putting it inside the collider the following way:

PolygonCollider2D collider = chunk.gameObject.AddComponent<PolygonCollider2D>();
List<Vector2> points = new List<Vector2>();

foreach (Vector2 vec in vertices)
{
    points.Add(vec);
}
collider.points = points.ToArray();

This almost worked, but it had some flaws in the collider:

Then I tried to use an EdgeCollider instead, but this made the character jitter. Lastly I tried to set each shape coming out of the marchingsquares algorithm be a separate path, but this was somehow very slow.

Is there any ways to create a good collider for a procedural surface?

Edit: Edge collider approach as requested (I got a bit further with it in the mean time):

So, to implement the edge collider, I changed my marching squares algorithm a bit, so it can output pure lines instead of actual triangles. The problem with this was that at some points, the character just randomly goes into the collider:


texts: What settings should the Root bone have in Blender for Unity?

texts: What orientation should the root bone have in Blender to behave correctly in Unity when using the Root Move?


texts: Libgdx libraries are missing from gradle cache after I reinstalled my system (IntelliJ)

texts:
I reinstalled my OS (Linux Mint) today and copied all my projects over to a flash drive. After I was done setting everything up I copied 'em back over again and started to fix the problems (caused by new jdk location, new android sdk, etc).

When I opened one of my libgdx game projects I found some errors (29) similar to the following:

Library gdx-1.6.1 has broken classes path:
  /home/gameplayjdk/.gradle/caches/modules-2/files-2.1/com.badlogicgames.gdx/gdx/1.6.1/bb5fe9832bcfe4bbc1de6bd357085b8a2a845d9c/gdx-1.6.1.jar [Fix]

Apparently the libgdx libraries are no longer present in the gradle cache, which makes sense since it's a whole new system.

Now I don't know how to make stuff work again. Any Ideas?


texts: Can you recommend a game server for a facebook board game?

texts:
I am seeking a game server that will scale well. All commercial and/or free software alternatives are welcome. Game will be a boardgame that is similar to poker. Some technical details are listed below.

There will be a table which consists of 4 people, to send them message I need a channel manager. A table will be ready to play for at least 5 minutes. There should be a reliable channel manager.
People will wait for some time(i.e.) and if they are not playing they will be kicked by server, so there will be a reliable timed task queue to execute some tasks.
It should be quick enough to response and show the changes to all 4 people on that table simultaneously.To achive this server should have a powerfull I/O library.
I think to use inmemory to have quick response times, but it comes with scalability problems.
And some variables should be thread safe so a variable should be thread safe between multiple nodes.
Flash(AS3) and Unity (.Net 2.0 C# mono) client API's should be available for socket connection.

PS: I am using Reddwarf server, it lacks of documentation and multiple node.


texts: How can I control how quickly a character levels up in an RPG?

texts:
I am working on an RPG and I've mostly followed formulas from the Dragon Quest series and they've all been fairly simple. (For example, dmg = (Attack/2 - Defense/4), where Attack is Weapon Power+STR.)

Experience points are more complicated though. I want one of the characters to level more slowly compared to the others. I'm not comfortable with the maths, but how would I go about creating a suitable exponential growth formula that is slow from let's say levels 1 through 40 and then speeds up to 99?


texts: Pygame - CollideRect - But How Do They Collide?

texts:
I'm having some trouble figuring out how I can handle collisions that are specifically colliding on the top or bottom a rect. How can specify those collisions?

Here's a little code snippet to give you an idea of my approach. As it is now it doesn't matter where it collides.

# the ball has hit one of the paddles. send it back in another direction.
    if paddleRect.colliderect(ballRect) or paddle2Rect.colliderect(ballRect):
        ballHitPaddle.play()
        if directionOfBall == 'upleft':
            directionOfBall = 'upright'
        elif directionOfBall == 'upright':
            directionOfBall = 'upleft'
        elif directionOfBall == 'downleft':
            directionOfBall = 'downright'
        elif directionOfBall == 'downright':
            directionOfBall = 'downleft'

Thanks in advance.

**EDIT**

Paddle rect:

 top
 ____
|    |
|    |
|    | Sides
|    |
 ----
bottom

I need to know if the ball has hit either  the top or the bottom.


texts:
So I want to create one of these in my directX11 project.

The little axis there that shows you the direction.

I have a nice 3d shader for my world geometry that I tweaked from Frank D. Luna (He writes books on directX.) and another for my 2D UI so I thought I'd look at those and see what I could conjure up since I didn't know all that much about shaders to begin with. But this is what I came up with.

float4x4 gWorldViewProj;

struct VertexIn
{
    float3 PosL    : POSITION;
    float3 NormalL : NORMAL;
    float2 Tex     : TEXCOORD;
};

struct VertexOut
{
    float4 PosH       : SV_POSITION;
    float2 Tex        : TEXCOORD;
};

VertexOut VS(VertexIn vin)
{
    VertexOut vout;

    // Transform to homogeneous clip space.
    vout.PosH = mul(float4(vin.PosL, 1.0f), gWorldViewProj);

    // There are no transformations for texture coordinates.
    vout.Tex = vin.Tex;

    return vout;
}

This code works if I pass in a quad and render a texture too it. Then for gWorldViewProj I give it just the world matrix of the UI. Renders fine.

But when I tried it with 3D objects (anything that wasn't a quad.) nothing would render. The only way I could get it to render is by passing in world * view * proj but then it rotates around the scene when you look around because of the view matrix.

So the obvious work around was to create a view matrix with no transformations and that worked.

I thought I could just give it a world matrix since that's what I did with the 2D UI. I also tried world * proj but no prevail. Why does this shader render quads without a view matrix but can't render other more complex sets of geometry without the view matrix. Here is how I generated the quad.


texts: Is it possible to use nav-mesh in 2d game in Unity?

texts:
I'm working on game that needs navigation and obstacle avoidance. I've used nav-mesh on 3d project before but now I'm trying to use it in 2d sprite game but it seems like it doesn't work.

I want to know if really it doesn't work and, if it doesn't, what would be a good replacement for a 2d project for the navigation of entities.

I'm looking for free tools.


texts:
I'm new in game development. I have a view using GLSurfaceview and call in MainActivity.

I want to make transparent that view. I have tried setZOrderOnTop() method in MainActivity and glClearColor() but both are not working.

public class RubikActivity extends Activity {

        cubeView cv;
        GLSurfaceView gv;

        @SuppressLint("NewApi")
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity);
        cv = (cubeView) findViewById(R.id.cubeView);
        cv.initialize(PreferenceManager.getDefaultSharedPreferences(this));
         cv.requestFocus();
            cv.setFocusableInTouchMode(true);
            cv.setEGLConfigChooser(8, 8, 8, 8, 8,0);
          //  cv.setRenderer( new CubeRenderer(getApplicationContext(), font, mWorld, rCube, mMenu, prefs);

            cv.getHolder().setFormat(PixelFormat.TRANSLUCENT);
        cv.setZOrderOnTop(true);

        }

cubeView.java

public cubeView(Context context, AttributeSet attrs) {
super(context, attrs);
font = new TextureFont(getContext(), R.drawable.roboto_regular, "roboto_regular_dims.txt");
mWorld = new GLWorld();

}

public void initialize(SharedPreferences prefs) {
rCube = new Rubec(mWorld, prefs.getInt("dim", 3));
mMenu = new CubeMenu(rCube, font);
_renderer = new CubeRenderer(getContext(), font, mWorld, rCube, mMenu, prefs);
rCube.setRenderer(_renderer);
mWorld.setRubeCube(rCube);
setRenderer(_renderer);

getHolder().setFormat(PixelFormat.TRANSLUCENT);
setZOrderOnTop(true);
}

cubeRenderer.java

@Override
public void onDrawFrame(GL10 g) {
GL11 gl = (GL11)g;

surfaceSetup(gl);

gl.glClearColor(1.0f, 1.0f, 1.0f,0);
gl.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
gl.glDisable(GL11.GL_DEPTH_TEST);
gl.glMatrixMode(GL11.GL_MODELVIEW);
gl.glShadeModel(GL11.GL_SMOOTH);
    gl.glLoadIdentity();

GLU.gluLookAt(gl, 0f, 0f, 7f,
          0f, 0f, 0f,
          0f, 1f, 0f);
gl.glGetFloatv(GL11.GL_MODELVIEW_MATRIX, modelViewMatrix, 0);
if(!worldBoundsSet) {
    getWorldBounds();
}
gl.glColor4f(0.5f, 0.5f, 0.5f, 1);
gl.glEnable(GL11.GL_DEPTH_TEST);
gl.glEnableClientState(GL11.GL_COLOR_ARRAY);
    gl.glEnableClientState(GL11.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
menu.draw(gl);
mWorld.draw(gl);
gl.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
/*gl.glDisableClientState(GL11.GL_COLOR_ARRAY);*/
gl.glDisableClientState(GL11.GL_VERTEX_ARRAY);

//gl.glFlush();
}

I want the white color to show as transparent background in my layout.
I am already use glClearColor(0,0,0,0) which shows as a black color
and already use in xml file:

 <com.rtpl.rubikgame.cubeView
  android:id="@+id/cubeView1"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_weight="1"
  android:background="#000000"
  android:windowIsTranslucent="true"/>
</LinearLayout>

but nothing happened; when we use glClearColor(0,0,0,0) it shows this:


texts: Equation for exponential deceleration so the objects “stops” at destination

texts:
Let's say my ship's velocity during deacceleration phase is given by:

v(t) = v0 * exp(-k * t)

where v0 is the speed at the time of starting deacceleration and k is arbitrary constant.

My problem is: Is it possible to calculate such k that the ship "stops" (let's say slows to a velocity vf) at the target position given:

v0
distance to the target d0
?

Or alternatively: given k calculating a distance at which deacceleration should start?

I'm making a space simulation game where the ship's warp drive needs to accelerate/deaccelerate exponentially. While accelerating to a maximum speed is easy the problem is with deaccelerating so that the ship "stops" at the destination.

Thank you in advance for any help.


texts: How do I determine if one polygon completely contains another?

texts: I have 2 polygons.  I know the vertex coordinates of both polygons.  What's the best way to check if one is completely inside the other?  For example, the algorithm should only recognize the black trapezoid below as being contained:


texts: Inertia Tensor and World Coordinate conversion

texts:
I understand that the inertia tensor is basically a 3x3 matrix. I'm modelling a cube, and the inertia tensor for this shape has values for moment of inertia on the main diagonal of the matrix. All the products of inertia are zero.

However, I understand that this matrix only makes sense in body (i.e., local) coordinates. That is if I have a cube and rotate it, its local coordinate axes rotate with it and the inertia tensor remains constant. However, I need to represent the inertia tensor in world coordinates as well. How can I do that? Do I need to multiply it by the current orientation? I'm using quaternions for orientation, so I can extract a matrix from the quaternion (a 4x4 matrix, and if I get rid of the fact that a 4x4 matrix represents homogeneous coordinates I could convert it into a 3x3. To do this I would simply get rid of the rightmost column and bottommost row of the 4x4 matrix returned from the quaternion).

I hope this is making some sense. I suspect that the values of the inertia tensor in world coordinates will change as the orientation of the cube changes.

Is my logic correct? Formulas would be helpful.

Cheers,

Mark


texts: What to do to set gravity in unity? I'm working on a game called "OXYGEN", and for the space scene. I want to set the gravity of the Controller to 0.38, or Mar's gravity.


texts: How to orient a layer to connect 2 points AND facing the camera

texts:
here is my question, which I hope will be in general interest:

If you have got 2 Points in 3D space and want a plane to connect those, you can quite easily use a function similar to "lookAt" to orient the layer pointing with its x-axis from one point to the other. But how can you at the same time make sure the layer is rotated in the way so that the layer is facing the camera (the maximum amount possible, of course it cant be orthogonal to the camera)?
The x Axis from the resulting plane should face from the one point to the other.


texts: Servers are never available to download CryENGINE

texts:
I have been having some trouble downloading the CryENGINE. I am directed to log in and download the engine through the CryENGINE Launcher, but whenever I try to log in, I get the error "Login failed. Server unreachable."

I can not find any reports of server malfunction, and others seem to be using it perfectly fine. This has gone on for over a week now. Whats going on?


texts: Is it still possible to develop for gamecube?

texts: I know the Nintendo gamecube is outdated, but it still one of my favorite systems. Is there any way to still develop games for it? What software would I need? What are the programming languages involved? Thanks guys!


texts:
I am learning Cocos2d-JS to develop web-based games with Javascript. In Cocos2d-JS there is project.json file which defines game configuration.

Is it possible to place this file in another location than the directory containing index.html or main.js and if so, where and how should I define the new path?


texts: What are the performance and size tradeoffs of Eigen::Transform versus Eigen::Matrix4f?

texts:
We finished migrating from DirectXMath to the Eigen math libraries for our 3D-Game Engine last week for portability reasons. After implementing transformations with matrices as we know them, we found out about Eigen::Transform, which seemed like a really cool idea at the time.

Now, after a lot of fiddling things still don't quite work and we don't seem to have as much control over the way that Transformations are made. With Eigen::Matrix4f, you're making the multiplications directly and can change in which order they are made. Eigen::Transform appears to be way less transparent and flexible.

So we thought about reverting to our commits from last week, and head on to work with matrices again. But there are a few things we are concerned about:

Saving things like translation in a 4x4 Matrix takes up more space than using Eigen::Translation
Generating a new Matrix4f for the complete transformation every tick seems like a tedious process

So I wanted to know how Transform compares to regular Matrix4f in terms of speed and if my impression that  Transform is not as flexible is actually true or not.


texts: User input scheme of 2d vector field on a 2d plane for navigation

texts:
I want to create a strategy game based on distributions of "units" which can be moved around and attack each other.
By distribution of units i mean that i don't have any discrete units instead is have a heat map which shows the concentration of units. If a group of units in attack range of enemy units the concentration in the area under attack will slowly dwindle.
Movement of a distribution of units thus follows a vector fields, allowing groups of units to be merged or split.

I have not decided whether i will only use the direction information or also the intensity/length (different parts are allowed to move at different speeds), this will depend on the input scheme.
How can i make user efficiently input and update such vector fields while still being able to move and zoom around?
One idea i had is to use a "potential" field and use the partial derivative to generate the vector field which might look like this:

However i am not sure that is the best idea. The input device i am targeting would be a mouse with scroll wheel. If you can come up with elegant input scheme for another input device ((pressure sensitive?) touch, controller, joystick, motion capture ...) i would also welcome the contribution.
How the input vector field will be used:
Bonus points, if you actually test your proposal.
In this case the update rule on a grid would be a discretization of this PDE (which is derived from the Fokker–Planck equation with no Diffusion):
$$\dfrac{\partial \text{Units}(x,y,t)}{\partial t} = -\dfrac{\partial}{\partial x}(\text{Units}(x,y,t)[\text{Input}_\vec{x}(x,y,t)+\text{Input}_\vec{y}(x,y,t)])  -\dfrac{\partial}{\partial y}(\text{Units}(x,y,t)[\text{Input}_\vec{x}(x,y,t)+\text{Input}_\vec{y}(x,y,t)]))$$
where $$ \text{Units}(x,y,t)$$ is the 2-d array containing the discretization of the distribution of units at time t and $$\text{Input}_\vec{y}(x,y,t)$$ is the y component of the vector field of the input vector field at coordinates x,y at time t.


texts: Unity 2D Input.gyro eulerAngles X value strange behaviour

texts:
I am working on a project where I want to create an 'scrolling' effect using gyroscope on mobile devices. The basic idea is that I have an Image object in my Scene and I want to be able to show different part of it using gyroscope like for example you see the wall of a room and rotation your phone you see different parts of the room, but in 2D.

For now I managed to move my Image using Input.gyro.attitude.eulerAngles.x; from gyroscope like this:

    protected void Update()
    {
        var x = transform.localPosition.x;
        var gyroX = Input.gyro.attitude.eulerAngles.x;
        x += -gyroX * Speed;

        BackgroundImage.transform.localPosition =
            new Vector3(x, transform.localPosition.y, transform.localPosition.z);

    }

The problem which I am seeing is that when Input.gyro.attitude.eulerAngles.x reaches 86.0 it starts decreasing and even if you are rotating your phone to right it changes it's direction.

Checked the documentation, examples over internet, but didn't find anything about that.

If you have any idea what can cause that issue and how can I fix it, or any other suggestions how can I achieve the thing which I want to create, pleae share your knowledge.

Thanks in advance!

Edit:
The only rotation axis which I am interested in is X, because the app will be in portrait mode and I want to be able to move the image only horizontal (by X).

So the phone's rotation has to be similar to while taking an panoramic photo on your mobile as shown on the first picture:


texts:
Can anyone tell me if geometry shaders are supported on the Microsoft Surface RT? On one hand, MSDN makes it sound like the Surface RT supports only feature level 9_1, and geometry shaders are only available in feature levels >= 10_0. On the other hand, there's this guy saying:

  Jesse Barker @incendy
  @dotMorten I am confused haha.. so my geometry shaders work on Surface rt?

  Morten Nielsen @dotMorten
  @incendy Yes ! They might run software emulation, but yes. That's why DX is so awesome. Don't worry about hardware. It'll work

Does anybody have actual experience with this? I don't have a Surface RT here to test with, so any guidance on this would be much appreciated.


texts:
I was wondering if GetInstanceID() is persistant at each run?

I intend to save/load gameobjects data by their ID....I needed a persistant ID


texts: How to balance a ball on a rotating plane?

texts:
I'm doing some research and I really don't want a physics engine when a simple mechanism will do.  I have a ball that will be balanced on a plane.  The ball will always be "stuck" to the plane and never roll off of it.  The player/user will be moving this plane vertically up and down, changing its angle (rotating it some) and changing it's length.  What I want is for the ball to roll along the plane as the user is interacting with the plane.

For example, player touches a surface with two fingers, touch 1 is the plane starting vector and touch 2 is the plane ending vector.  The player can then move the two fingers around (increasing/decreasing the length of the plane) as well as move their fingers vertically and horizontally changing the planes position in 2d space.  While doing this the ball moves along the plane with normal gravity trying to pull the ball down to the ground.

Does anyone have any idea on how to approach this?  I started to think that this would be simple but then figuring in the dynamically changing length of the plane I got a bit lost.

I'll be doing this in XNA or Silverlight.


texts: Keeping ratio the same across devices on fixed screen game

texts:
My game is an Android game using OpenGL ES 2.0 (But this question could apply to any platform).

I have read many questions on here regarding ratio management, and also read many tutorials outside of this site, but I'm still really confused as to how to manage this.

My game is a Fixed screen 2d platformer.  By fixed screen, I mean the player sees the whole screen at once and the screen doesn't scroll.  All action takes place on this one screen (kind of like Bubble Bobble).  Therefore scrolling is not possible as we need to see the whole play area.

On my development device, I've written everything to look perfect, like so:

What I've currently done is when the game is run on other devices, I resize my GLViewport so that I maintain ratio like so:

Obviously, this has it's own problem - namely, it wastes screen real-estate. Now, I would accept this reluctantly, if I couldn't find a better solution, however, Google's documentation states that it's not allowed (of sorts) see: App uses the whole screen in both orientations and does not letterbox to account for orientation changes.

So, finally, I just stretched it out to fit the screen like so:

This takes the whole screen, but frankly looks a little naff as everything is stretched.

Am I out of options?  I see some similar games on the Play Store (ie, fixed screen) and they seem to look identical on different screens (and nothing is stretched) and there doesn't appear to be any extra space, but I have absolutely no idea how they achieve this.  Would love to hear from someone who has dealt with this problem themselves or has any ideas on how best to proceed.


texts: Mouse position to grid position not working

texts:
I have a function which converts my mouse position to grid position in the game but it is not working properly... its slightly off.

I have two functions - one which converts from grid to screen position (this particular one, works fine) and the code is:

function mapToScreen(gridX,gridY,screen) {
    var grid = 64;
    var x  = (gridX - gridY) * (grid/2);
        x -= screen.offsetX; //camera scroll offset X axis
        x -= grid/2; //centre of the iso tile on X axis

    var y = (gridX + gridY) * (grid/4);
        y -= screen.offsetY; //camera scroll offset Y axis
        y -= grid/4; //centre of the iso tile on Y axis
    return [x,y];
}

So my function to do the opposite looks like this:

function screenToMap(pixelX,pixelY,screen) {
    var grid = 64;
    pixelX += screen.offsetX;
    pixelX += grid/2;
    pixelY += screen.offsetY;
    pixelY += grid/4;

    var gridX = Math.floor((pixelX / (grid/2)  + pixelY / (grid/4)) /2);
    var gridY = Math.floor((pixelY / (grid/4)  -(pixelX / (grid/2))) /2);

    return [gridX, gridY];
}

The problem is as shown below in the image, it doesn't return the correct number. The first corner tile should be [0,0].

Also notice the co-ordinate doesn't change correctly with the tile border. I don't know how to solve that either.


texts: Rotate an object smoothly by using Accelerometer Input in Unity

texts:
There is a simple script where the object orientation is equal to the mobile devices orientation.

it works but the object doesn't rotate smoothly.

void FixedUpdate()
{
    float accelx = Input.acceleration.x;

    float angle = Mathf.Asin(accelx) * Mathf.Rad2Deg;

    transform.eulerAngles = new Vector3(angle , 0, 0);
}

How to rotate an object smoothly by using Accelerometer Input ?


texts: Should I use single state or multiple state of an entity in finite state machine?

texts:
In the below code, is the options I've created whether to use single or multiple states for my character or other entity. Still can't decide which one is better inf using state machines.

public enum CharacterState implements State<Entity> {

    animation // ...
    movement // move_down, move_up ...

}

public enum AnimationState implements State<Entity>
public enum MovementState implements State<Entity>


texts: Where to purchase multitrack music loops?

texts: I've seen other questions about where to find royalty-free music available for purchase. But most of these tend to provide a single audio file with every instrument track already blended and mixed together. I'm more interested in the dynamic music route, and would want to download a bundle of audio files (one for bass, one for kick, etc) and in my game I can just bring them in and out based off of what's going on. When things are quiet just have the bass line repeating and when things get chaotic the full piece is going. Obviously each track would need to be on the same beat and designed to work well with each other part. Is there any place that such multitrack loops could purchased? Thanks.


texts: I want to create a map similar to how Mincraft and other related games do. I just haven't the faintest clue on how to do so. Can anyone point me to a decent tutorial or give me a decent run through? I program in java and use openGL.


texts: Is it possible in Unity to Flip a 2D Sprite Without Flipping the Object it is Assigned to?

texts:
I 'built' (followed a tutorial) on a collision detection system, and when I flip the object to go left and right the collision messes up. So I have three options; find a way to modify the collision detection, have sprites for all animations for left and right or to flip the sprite but no the object.

if anyone has used RaycastHit2D, and has figured out a way to do it correctly, that would also be great.


texts: Unity Rigidbody gets pushed through collider by another rigidbody?

texts:
I'm setting up the interior of a house in a 2D platformer. Inside the house is an NPC with a box collider and rigidbody attached, and the house is boxed in by four edge colliders. My character also has a collider and rigidbody.

My NPC walks back and forth randomly, but when he pushes my character into the wall, the force of the push takes priority over the house's edge collider and my character gets pushed outside.

Is there any way to give priority to the house's collider somehow, without removing the NPC's rigidbody?


texts: How to implement mouse based movement in an RPG? (Java)

texts: I'm making a 2D rpg and I want the character to move with the mouse, ie the user clicks and then the character moves to that location. How do I accomplish this?


texts: How to instantiate a gameobject multiple times in unity during runtime?

texts:
After destroying a gameobject in unity, how to instantiate it and make it do the exact same thing what the gameobject before getting destroyed was doing? My gameobject is a car which follows a path made out of nodes. After it is destroyed at a particular node, I want to instantiate it at a particular point which is the spawnSpot in my code, then I want it to follow the same path again and then get destroyed again and get instantiated again and follow the same path again and so on.
Right now, I am able to make my car follow a certain path and then destroy it at a certain node and and instantiate it and make it follow the same path again. Then my car is destroyed again and instantiated again but this time it does not follow the path and stays right at the spawnPoint.
I am using the destroy and instantiate functions in fixed update. Here's the relevant part of my code:

private void Destroy()
{
    if(currentNode == nodes.Count - 1)
    {
        Destroy(this.gameObject);
    }
}

private void Instantiate()
{
    if(currentNode == nodes.Count - 1)
    {
        Instantiate(prefab, spawnspot, Quaternion.identity);
    }
}

P.S. prefab is the gameObject.


texts: Looking for an example of glass with XNA or DirectX 9

texts: Any good pointers on how to get the refractive look of glass? I'm looking to create a think piece of glass type of look, sort of the type that you'd have on bathroom shower doors.


texts: Unity Project Settings: What is the difference between "Graphics -> SRP settings" and "Quality -> Rendering -> URP Asset"

texts:
As the title says, I am a bit confused about the aspect that the URP asset is referenced from two different settings:

"Project Settings -> Graphics -> SRP settings"
"Project Settings -> Quality -> Rendering -> URP Asset"

In a blank URP Project, "Project Settings -> Graphics -> SRP settings" references the HighQuality URP asset, and "Project Settings -> Quality -> Rendering -> URP Asset" has three different tiers, all of which reference their respective URP assed (i.e., either LowQuality, MediumQuality, or HighQuality.
Switching from one quality tier to another applies the respective URP asset, i.e., if I switch the quality tier to Low, the LowQuality URP asset is applied, even though the HighQuality is still set in "Project Settings -> Graphics -> SRP settings".
So now the question: Why do I have to set a URP asset in "Project Settings -> Graphics -> SRP settings" if it seems that it is overridden by the URP asset defined in the quality tab?


texts: How to create a Unity Editor box grouping with a header and vertically stacked content inside?

texts:
I am trying to do something like this with Unity Editor for my window but I am not sure how it is done.

So it is basically a box ( a wrapper ) with a title at top. Beneath the title there are boxes or "cards" where you add text to it.

Any help is appreciated!


texts: Gravity vector and forward vector to local heading (yaw), pitch and roll

texts:
I've looked around for hours and I simply don't get it. I am the first to admit I am severely lacking in mathematics. So please, keep it simple.

I am trying to get a vectors rotation (angle) around another vector so i can get useful Yaw, Pitch and Roll from said vectors.
This on a "vehicle" that has a forward vector (and of course accompanying right and up vectors) which is "flying" over a planet (sphere) with gravity going towards it's center. This gravity vector is also known.

Here's an example of what i am looking at:

I am using Unity to EXPERIMENT with. The goal is to implement this in another project. Thus, all the powers of Unity doesn't help me find a solution for my other project. I am constricted to Vector3.Cross(), Vector3.Dot, Math.Cos/Sin/ACos/ASin/Tan/ATan/ATan2 etc.

Here's the code i have. I did remove all the calculations i tried beforehand as they all failed and i'd rather have a clean answer.

    // Time that debug lines and rays will be displayed for.
    var duration = Time.deltaTime;
    // Draws a line through the south/north poles of the sphwere.
    Debug.DrawLine(Vector3.down * 100, Vector3.up * 100, Color.cyan, duration, false);

    // Gravity that affects the vehicle
    var gravity = Vector3.Normalize(planet.transform.position - transform.position) * 9.81F;
    Debug.DrawRay(transform.position, gravity, new Color(0.4F, 0.0F, 0.0F), duration, false);

    var gravityEast = Vector3.Cross(gravity.normalized, Vector3.down).normalized;
    var gravityNorth = Vector3.Cross(gravityEast.normalized, -gravity.normalized).normalized;

    Debug.DrawRay(transform.position, gravityEast, Color.yellow, duration, false);
    Debug.DrawRay(transform.position, gravityNorth, Color.white, duration, false);
    Debug.DrawRay(transform.position, transform.forward * 0.5F, Color.blue, duration, false);

    text.text = "gravity: " + gravity + "\n";
    text.text += "gravityEast: " + gravityEast + "\n";
    text.text += "gravityNorth: " + gravityNorth + "\n\n";

    text.text += "forward: " + transform.forward + "\n\n";

I am looking to get Yaw in 360 degrees (-180 to 180 works too and even radians, that's not a problem), roll in -180 to 180 degrees and pitch in -90 to 90 degrees.
This all in respect to the gravity vector and where zero Yaw is pointing to the north along the sphere. 90 Yaw is east, 180 is south and 270 is west.

As i said, i've been looking at hundreds of different examples (both on SE and elsewhere) and i still don't understand how to do this.
All the things i have tried have either not worked at all or they have worked only in certain circumstances such as the "vehicle" being on one side of the sphere but not the others.
As far as i can understand, i need to transform the calculations to local vector space so that the formulas stay relative to my ever changing gravity vector.

And because i am mathematically illiterate at best, a bunch of mathematical formulas won't really help me. I've looked at them all and it just doesn't click.
Instead, if this can be shown in pseudocode or even straight up C# that would be optimal.

And just to be perfectly clear here. I know i can use "transform.eulerAngles" on my cube to get global and local angles right away. Again, i need to port the solution to another project that doesn't come with those simple properties/fields.

Thank you!


texts: How can I convert a Tiled level array to a 2D array?

texts:
For the code in my game, I want a 2D array which represents the map.

I created an actual map with Tiled but it produces a 1D array. Is there any way to convert it into my desired format wothout manually adding brackets and commas after each line?


texts: Optimal data size for a 3G client-server game?

texts:
I'm currently working on an iOS turn-based client-server game and I am concerned over later performance issues.

How much data per message is too big? I am planning to use JSON to transfer data (and, if possible, gzip it for more compression) and try to send as little as possible to make it work, but is there a figure I should keep in mind so that I do not exceed and is there a best-practice way of compressing this data?

On a side note, will this prevent me or affect whether I will use secure connections like SSL?


texts: Now that Device Central is dead, how can I test my Flash Lite applications?

texts:
I'm trying to use Flash Lite to make a simple game for my girlfriend, who only has a Nokia 5530, but I just realized in CS6 Adobe killed Device Central, so there's no way for me to test it without the device (and it's supposed to be a surprise).

Is there any other way for me to test it? I know I can just export the movie and use Flash Player, but Device Central allowed me to test drag and drop and memory/processor usage for example...

tl;dr, is there an alternative to Device Central for testing Flash Lite in older devices?


texts: How to Access a Field of an Unknown Class if the Field Exists

texts:
It's a very poorly worded question because I'm not exactly sure how to put it into words that are of appropriate number for a title. Read on for a better explanation. (Using Unity API, C#)

Basically, I have an AI class in a spaceship game. I can assign the AI a target GameObject, and the AI will look in the direction of and chase after it's target. I would like to make the AI be able to strafe in circles around the target. Since the AI always faces its target, I can simply TransformDirection(Vector2.left/right) and it will orbit the target nicely, but if the target is moving it always breaks orbit.

To combat this, I want to add the target's velocity to the strafe velocity of the AI. However, I have different classes for the player's ship and the AI ships whom also might be targeted by another AI. All of my ship classes have a field for the ship's velocity, but since they are different classes, I thought I may access the velocity field by doing a GetComponent() and passing some sort of predicate => T has a Vector2 field named "velocity". Is there some way to achieve this?


texts: How can I add a delay to my enemy spawning in Greenfoot?

texts:
How can I add a delay between spawning my enemies in Greenfoot? I'm doing it from a class that is neither a world nor an actor, its made totally by me. I need to it spawn 3 enemies, 3 times, with a 1-second delay between each time. Here's what I've got now.

void attack()
{
    long beginTime = System.nanoTime();
    int i = 0;
    while(i < 3)
    {
        if ((System.nanoTime()-beginTime)/1000000000>1f)
        {
            for (int j = 0; j < 3; j++)
            {
                world.spawnEnemy();
            }
            i++;
        beginTime = System.nanoTime();
        }
    }
}

It's based off of this answer to this question. However, it does not at all give me the desired results. Instead, it entirely pauses everything else in the game (all of the actors, probably the world too, but I'm not sure) until the makeshift timer ends 1 second into it, and then spawns all 3 waves (all 9 enemies) at once.


texts: A* pathfinding algorithm to identify entrances into current "room"?

texts:
Was looking for some online articles that might have a good idea or two in how to approach this but not finding much. Most of it deals with the various ways to generate and follow a path to a known destination type.

Basically the idea is that you have an existing node graph and want to utilize that data in order to locate entrances into the current area an AI unit would want to defend. So think of an AI unit assigned a task of defending a point with a radius and wanting to choose the best direction to face while waiting for enemies to show up that would be pathing to the defend point.

The critical point that I was looking for input on would be how one might identify the entrance points. Or the nodes that are the doorways into the area being defended.

The best idea thought of would be to do a breadth first outward search from the defend point and identify nodes that can see the defend point, have links, but none of the linked nodes can also see the defend point.


texts: Is there a way to rotate a TexturePaint?

texts:
I wanted to add a grass texture to my 3D polygon-based game, and thought the easiest way to do it was to use a TexturePaint. Currently, the texture stays fixed while the world rotates which isn't the look I'm going for. In order to fix this, I tried using an AffineTransform to rotate the actual image, so that the pattern would come out rotated and would follow the world as it rotated, but this lead to the texture cropping weirdly and didn't work.

This is the code I tried in order to rotate the texture (which doesn't work correctly):

    double rotationRequired = radSpin;
    double locationX = grassImage.getWidth()/2;
    double locationY = grassImage.getHeight()/2;
    AffineTransform tx = AffineTransform.getRotateInstance(rotationRequired, locationX, locationY);
    AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR);

    grassTexture = new TexturePaint(op.filter(grassImage, null), new Rectangle((int)worldX, (int)worldY, (int)(scale*128), (int)(scale*128*getShrink)));

This is run every time the game is painted.

This is what my game looks like when I run the failed code:  https://youtu.be/9U-9RqyDyj4


texts:
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
  - Chinese Proverb

I could ask what kind of data storage I should use for my actual project, but I want to learn to fish, so I don't need to ask for a fish each time I begin a new project.

So, until I used two methods to store data on my non-game project: XML files, and relational databases. I know that there is also other kind of database, of the NoSQL kind. However I wouldn't know if there is more choice available to me, or how to choose in the first place, aside arbitrary picking one.

So the question is the following: How should I choose the kind of data storage for a game project?

And I would be interested on the following criterion when choosing:

The size of the project.
The platform targeted by the game, as well as the development platform used.
The complexity of the data structure.
Added Portability of data amongst many project.
Added2 Silmutaneous use of the data amongst different project. (i.e. User data)
Added How often should the data be accessed
Added Multiple type of data for a same application
Added2 Configuration with multiple data storage.
Any other point you think is of interest when deciding what to use.

EDIT I know about Would it be better to use XML/JSON/Text or a database to store game content?, but thought it didn't address exactly my point. Now if I am wrong, I would gladely be shown the error in my ways.

EDIT2 Added some more points that I would consider relevant. Furthermore, I would be interested to hear what other options are available, aside flat file storage and relational database. What about non-relational database, for example? When it is relevant to use such a database over the formerly mentioned other options?


texts:
I'm trying to get into Farseer and XNA.
Before I do any real graphics, I want to use the Farseer debug view only.
The problem ist, that I don't really know which matrix to use and the other thing is that my objects look "squeezed". But in detail:

this.oGraphicsMgr.SupportedOrientations = DisplayOrientation.Portrait;
this.oGraphicsMgr.IsFullScreen = false;
this.oGraphicsMgr.PreferredBackBufferWidth = 640;
this.oGraphicsMgr.PreferredBackBufferHeight = 960;
this.oGraphicsMgr.ApplyChanges();

this.oWorld = new World( Vector2.Zero );

My gaming field is 640x960 screen units (pixels).

The setup of the debug view:

this.oDebugView = new DebugViewXNA( this.oWorld )
{
    DefaultShapeColor = Color.Red,
    SleepingShapeColor = Color.Pink,
    StaticShapeColor = Color.Yellow,
};
this.oDebugView.LoadContent( this.GraphicsDevice, this.Content );
this.oDebugView.AppendFlags( DebugViewFlags.Shape );
this.oDebugView.AppendFlags( DebugViewFlags.DebugPanel );
this.oDebugView.AppendFlags( DebugViewFlags.PolygonPoints );
this.oDebugView.AppendFlags( DebugViewFlags.CenterOfMass );
this.oDebugView.AppendFlags( DebugViewFlags.Controllers );

I create a circular body and place it in the middle of the screen. "Puck" inherits from Body.

public Puck(World oWorld) : base( oWorld )
{
    FixtureFactory.AttachCircle( 0.1, 1f, this );
    this.Restitution = RESTITUTION;
    this.BodyType = FarseerPhysics.Dynamics.BodyType.Dynamic;
}

My game's draw method:

protected override void Draw( GameTime oGameTime )
{
    GraphicsDevice.Clear( Color.CornflowerBlue );
    Matrix oProj = Matrix.Identity;
    this.oDebugView.RenderDebugData( ref oProj );
base.Draw( oGameTime );
}

The output is a window that is 640x960 pixels. In the middle I can see what is supposingly a circle but it is drawn elliptical: twice as high as it is wide.

It will only be shown as a circle if my game field's width and height are equal. As soon as they differ, the debug view draws all objects stretched using the ratio of width to height. Why? How to avoid?
I'm not using a camera. After long trying I figured out that Matrix.Identity is the only projection matrix that will actually make the debug view draw everything in the correct size. But to my understanding it should instead be a scaled matrix, transforming my physic units into screen units.
I want my gaming field to be 3x2 meters and the puck 0.2m diameter. Therefore I will have to define a scale factor from sim units to screen units. But nowhere can I see that the debug view would require this. How can it possibly know how big a shape has to be drawn?


texts: searching for "university kind"  free online course about OPENGL

texts:
I know there are a lot of free university courses, but I'm trying to find one about OpenGL.
Do you know where can I find one, online?


texts: Adding multiple animated sprites on canvas make the game FPS drop sharply

texts:
I am using PIXI.js to build a html5 canvas game. Although this is PIXI.js specific question I think this may happen very often in HTML5 canvas games.

I have placed hundreds of static sprites in my game and all goes well. But when I try to add 30 animated sprites (AI players) in the game, the FPS drops from 60 to 30. If I add even more it becomes very slow and unplayable. I have profiled my program on Chrome and found that this method

CanvasSpriteRenderer.prototype.render

is using too many CPU resources. Is there a way to reduce the CPU consumption and make my game smooth again?


texts: How can I fade player character when he goes inside or outside of the area?

texts:
I want to fade the player when he goes out of the area.

For example, suppose a person enters a building. When a person is outside of the building, he shouldn't be seen, but when he enters he gradually becomes visible (using fading effect).

when elephant is inside green area his alpha should be 1

when elephant is outside of green area his alpha should be 0


texts: Creating the nodes for path finding during run time - more like path making and more

texts:
I'm making my 1st game. I'm using javascript as I currently want to learn to make games without needing to learn another language but this is more of a general game dev question.

It's a 2d turn-based tile/grid game. You can check it here http://www.patinterotest.tk/
it creates a movable area when you hover a player and it implements the A* algorithm for moving the player.

The Problem: I want to make the 'dynamic movable area creation' already implement a limited number of steps for a player.

The Questions:

What is a good way to do this?
Is there another algorithm to use for this?
The A* algorithm needs a start and destination, with what I want to do I don't have a destination
Or should I just limit the iteration of the A* algorithm to the steps variable?


texts:
How do I go about moving a bounding box in libGDX?

I want to make the bounding box capture my character and move with him.

So ideally I want to be able to copy my vector 3 from my model instance and set it on the bounding box.

There doesn't seem to be any method like setToTranslation() on the BoundingBox class. How am I supposed to do it?


texts: I am developing basic XNA car game. I used 3D fbx car models to represent car objects. I drag and drop all tga and fbx files into content and I succesfully showed car in my game by using some basic codes. But the problem is when I move the car around the components move around irrelevant because some components of fbx model have different X, Y, Z directions according to world. I tried a lot of fbx models but all of it same. Also the colors have not shown on game. What is the solution of this broblem. How can I equal all component axes to game world axes to move around together? Why I can not see the colors of components?


texts: Flash, Java, Unity plugin install penetration?

texts: Is there data on how many users have Flash, Java, or Unity plugins installed?


texts:
I have begun creating a very simple game engine and I am trying to work out how to create a time scale for the game. By time scale I mean some way of increasing and decreasing the speed of the game (not the fps) like creating a slow motion effect.

I have no idea how this could be accomplished so any help would be appreciated.

If this helps I'm using windows, OpenGL, and C++ to make my game engine.

How my engine is setup:

I have an update and draw function. The update function is called 25 times per second while display is called as much as possible.


texts:
I'm coming to the end of my first year of CS which has been primarily a Java based course. I'd like to get my feet wet with some game development but I'm not sure where to start.

Some people have suggested I start with game maker which has a C-styled scripting language(which should be easy to pick up) as it is probably the simplest and allows me to focus mainly on the game design and how the whole game fits together.

I see a lot people recommended XNA, as it has good abstraction of opengl and directX through its APIs. I also hear C# is very similar to Java.

I have also considered game programming in Java since I am quite comfortable with it and have been doing extra reading on multi-threading and the 2d graphics APIs.

Finally, a friend has recently shown me pygame which also sounds very good although I don't know all that much about it.

I don't know if C++ is a good starting point, a lot of the posts I've seen for beginner game devs don't recommend it for a first game project.

I'd appreciate any input, especially from those who got into game dev from a Java background


texts:
I did have JOGL1.1 set up and working, but I soon discovered that it did not support the latest OpenGL, so I started work on upgrading to JOGL2.0 it's not gone too well.

Firstly, is it worth me trying to get JOGL to work, or should I just move over to LWJGL? I am fairly comfortable with OpenGL (via C++) and from what I did get working with JOGL1.1, I seem to be OK adapting to it.

Assuming that I stick with JOGL, am I foolish for trying to use JOGL2.0? From what I can gather, JOGL2.0 is still in beta, but I am willing to go with it as I want to make use of the latest OpenGL I can.

I have been using the Eclipse IDE and have set up a user library for JOGL, here is a screen shot of the configuration and I have added this user library to my own Eclipse project. the system variable %JOGL_HOME% points to "C:\Users\edacosh\Downloads\JOGL2.0" so that should work fine.

Now, the problem I actually having, when I try to run my code, on the line

GLProfile glp = GLProfile.getDefault();

The code stops with the following message...

Exception in thread "main" java.lang.NoClassDefFoundError: com/jogamp/common/jvm/JVMUtil
    at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:1145)
    at DiCE.DiCE.<init>(DiCE.java:33)
    at App.<init>(App.java:17)
    at App.main(App.java:12)
Caused by: java.lang.ClassNotFoundException: com.jogamp.common.jvm.JVMUtil
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 4 more

I have also set my project to ensure that it is using jre6 along with jdk6, as I was having some issues.


texts:
I am having a problem in this question. I want a system inside a game wherein the player draws 2 cards randomly, and the enemy draws 2 cards randomly. Then, what the program does is to print out to the console the cards the player draw and the enemy's. The cards should not conflict and must not be the same. Then lastly, the program prints out the card that was not drawn by both the player and the enemy. Here's how I did it but it was lengthy and full of errors:

import java.util.Random;
public class Draw {

    public static Random random = new Random();
    public static String cards[] = {"Hall", "Kitchen", "Billiard", "Study", "Pool"};
    public static int playercounter;
    public static int enemycounter;
    public static String playercardA = null;
    public static String playercardB = null;
    public static String enemycardA = null;
    public static String enemycardB = null;
    public String lastcard = null;

    public static void playercardAdraw() {
        playercounter = random.nextInt(5);
        playercardA = cards[playercounter];
    }

    public static void playercardBdraw() {
        playercounter=random.nextInt(5);
        playercardB= cards[playercounter];
            if (playercardB==playercardA || playercardB == enemycardA || playercardB == enemycardB) {
                return;
            }
    }

    public static void enemycardAdraw () {
        enemycounter = random.nextInt(5);
        enemycardA=cards[enemycounter];
            if (enemycardA == playercardA || enemycardA == playercardB) {
                return;
            }

    }

    public static void enemycardBdraw () {
        enemycounter = random.nextInt(5);
        enemycardB=cards[enemycounter];
            if (enemycardB == playercardA || enemycardB == playercardB || enemycardB == enemycardA) {
                return;
            }
    }

    public static void main (String args []) {

        System.out.println("Starting to draw...");
        System.out.println("Player's Turn: ");
            playercardAdraw();
        System.out.println("Player's first card: " + playercardA);
            playercardBdraw();
        System.out.println("Player's second card: " + playercardB);
        System.out.println("Enemy's Turn: ");
            enemycardAdraw();
        System.out.println("Enemy's first card: " + enemycardA);
        enemycardBdraw();
        System.out.println("Enemy's Second card: " + enemycardB);
    }

}


texts: What do I need to legally use copyrighted music in my game?

texts: I asked the singer of a song I am using, and he agreed to me using his music, provided I credit him. Do I need anything else, such as an agreement or signature?


texts: Libgdx + Ashley moving one texture causes everything to jump

texts:
My problem is that as i am moving my player entity all my entities shift position by the reverse total of my player entities movement vector, However the only system to move things is my MovementSystem class which moves a entity by its own movement vector and is clamped by delta Time.

MovementSystem

public class MovementSystem extends IteratingSystem
{

    private ComponentMapper<MovementComponent> movementComponentMap;
    private ComponentMapper<TransformComponent> posComponentMap;
    private ComponentMapper<DebugComponent> debugComponentMap;

    public MovementSystem()
    {
        super(Family.all(MovementComponent.class,  TransformComponent.class,
            DebugComponent.class).get());

        movementComponentMap = ComponentMapper.getFor(MovementComponent.class);
        posComponentMap = ComponentMapper.getFor(TransformComponent.class);
        debugComponentMap = ComponentMapper.getFor(DebugComponent.class);
    }

    @Override
    protected void processEntity(Entity entity, float deltaTime)
    {
        TransformComponent pos = posComponentMap.get(entity);
        MovementComponent mov = movementComponentMap.get(entity);
        DebugComponent db = debugComponentMap.get(entity);

        pos.Position.x += mov.Velocity.x * deltaTime;
        pos.Position.y += mov.Velocity.y * deltaTime;
    }
}

RenderSystem

public class RenderSystem extends SortedIteratingSystem
{
    private ComponentMapper<TextureComponent> textureComponentMap;
    private ComponentMapper<TransformComponent> transformComponentMap;
    private ComponentMapper<DebugComponent> dbMap;

    SpriteBatch batch;
    OrthographicCamera camera;

    public RenderSystem(SpriteBatch batch)
    {
        super(Family.all(TransformComponent.class, TextureComponent.class).get(), new RenderComparator(), 50);

        textureComponentMap = ComponentMapper.getFor(TextureComponent.class);
        transformComponentMap = ComponentMapper.getFor(TransformComponent.class);
        dbMap = ComponentMapper.getFor(DebugComponent.class);
        this.batch = batch;
        camera = new OrthographicCamera(CONST.FRUSTRUM_WIDTH, CONST.FRUSTRUM_HEIGHT);
    }

    @Override
    public void update(float deltaTime)
    {
        camera.update();
        batch.setProjectionMatrix(camera.combined);
        batch.begin();
        super.update(deltaTime);
        batch.end();
    }

    @Override
    public void processEntity(Entity entity, float deltaTime)
    {
        TextureComponent tex = textureComponentMap.get(entity);
        TransformComponent pos = transformComponentMap.get(entity);
        DebugComponent db = dbMap.get(entity);

        batch.draw(tex.Texture, pos.Position.x - tex.TextureOrigin.x,
            pos.Position.y - tex.TextureOrigin.y,
            tex.TextureOrigin.x, tex.TextureOrigin.y,
            tex.Texture.getRegionWidth(), tex.Texture.getRegionHeight(),
            pos.Scale.x, pos.Scale.y,
            MathUtils.radiansToDegrees * pos.Rotation);
    }
}

The full code can be found on my github profile

i have no idea what is happening. i have been over my code with a fine toothed comb and lots of console output and i just cannot find a reason for everything to be jumping by essentially the speed of the player. any thoughts or nudges in directions would be greatly appreciated


texts:
I have in mind coding a multiplayer game with a similar combat to zelda's. Since i will use flash, i'm limited to use TCP. My question is, is this goal possible? It's not as fast-paced as some shooters, but i'm not sure if it's too much for tcp?

tl;dr: TCP for zelda-like multiplayer combat style?


texts: Javascript canvas rotating single sprite instead of entire context

texts:
I am trying to recreate asteroids, but I need the ship to rotate based on user input. I have w,a,s,d keys set to change the [pos] of the ship by 1 in the corresponding direction, but now, I need to spawn the sprite in the appropriate angle based on that, and I am running into two main issues:

how to correctly spawn the image over and over (right now, I can get a copy of the ship to spawn in the exact cetner of the context, rotated at one angle, ALONG with the real ship that I control. I do not know why this is.)
How to calculate the angle of rotation in radians based on the ship's pos.

I have included the entire ship class, but the most relevant code will be the draw method at the bottom.

const Utils = require('./utils.js');
const MovingObject = require('./moving_object.js');
const Bullet = require('./bullet.js');

function Ship(posOptions) {
  let options = {game: posOptions['game'], color: 'green', pos: posOptions['pos'], radius: 20, vel: [0,0], wrappable: true, type: 0}
  MovingObject.call(this, options);
  this.faceingDir = [0,0];
}

Utils.inherits(Ship, MovingObject);

Ship.prototype.relocate = function () {
  this.pos = this.game.randomPosition();
  this.vel = [0,0];
};

Ship.prototype.power = function (impulse) {
  // console.log(this.vel);
  this.vel[0] += impulse[0];
  this.vel[1] += impulse[1];
};

Ship.prototype.fireBullet = function () {
  let bulletVel = [(this.vel[0] * 4), (this.vel[1] * 5) - 10];
  let bullet = new Bullet({pos: this.pos, vel: bulletVel, game: this.game});
  this.game.bullets.push(bullet);
};

Ship.prototype.move = function () {
  if (this.isWrappable) {
    this.pos = this.game.wrap(this.pos);
  }
  this.pos[0] += this.vel[0];
  this.pos[1] += this.vel[1];
  this.vel[0] *= .98;
  this.vel[1] *= .98;
};

Ship.prototype.draw = function (ctx) {
  const img = new Image();
   img.onload = function () {
    ctx.drawImage(img, this.pos[0]-this.radius, this.pos[1]-this.radius)

  };
  img.src = 'galaga_ship.png';
  ctx.drawImage(img, this.pos[0]-this.radius, this.pos[1]-this.radius);
  var x = 800 / 2;
  var y = Math.floor(605 / 2);
  var width = img.width;
  var height = img.height;
  ctx.translate(x, y);
  ctx.rotate(10 * Math.PI / 180);
  ctx.drawImage(img, -width / 2, -height / 2, width, height);
  ctx.rotate(-10 * Math.PI / 180);
  ctx.translate(-x, -y);
};


texts: How to properly overflow 2D coordinates on an overflowing/circular map?

texts:
I made a simple Snake game designed for trying Snake bots. I thought the base map functions work, but now I found there is an error. What I need is to properly translate any coordinates outside the actual map to coordinates within it.
For example, if you're at the right edge of a 10x10 map and you go to (zero-indexed) [10, 5], you'd expect to pop out at [0, 5]. That works in my implementation, but not the negative overflow. I tried a lot of formulas in the dev console and just can't figure it out. Consider this code:
    /**
     * Normalizes overflow of a point so that it is within the map
     * @param {number|Vector2} x
     * @param {number} y
     * @returns {Vector2}
     */
    normalizePoint(x, y) {
        if (x instanceof Vector2) {
            y = x.y;
            x = x.x;
        }

        // auto overflow
        if (x >= this.size) {
            x = (x % this.size);
        }
        else if (x < 0) {
            // ???
        }
        if (y >= this.size) {
            y = (y % this.size);
        }
        else if (y < 0) {
            // one of the formulae I tried, does not work for all values
            y = this.size + (y-1) % this.size;
        }
        return new Vector2(x, y);
    }

Vector2 is a simple object with properties x and y. this.size represents the map size. For negative coordinates, I am not getting the correct results. I want overflowing X and Y coords to resolve to the same numbers. For example for a 5x5 map, all rows should be equal X coords after normalizing:

Real map coord X:
0
1
2
3
4

Negative alternatives:
-5
-4
-3
-2
-1

Negative alternatives:
-10
-9
-8
-7
-6

I would prefer it to be a O(1) formula, rather than some weird loop. With a loop, I solved it like this:
if (x < 0) {
            while (x < 0) {
                x += this.size;
            }
        }

```