Tag Info

New answers tagged

-1

you can do it in HTML5 and javascript then use mysql for database then everyone can play the game from your website otherwise you cant go wrong with unity I suppose but I dont have any experience with that.


0

Unity 2D would work well for this. Perhaps the biggest advantage is a built in level editor. Another huge advantage is the portability of Unity games. You'll easily be able to "port" your game between platforms. It does provide networking, though you might find that it's far less user friendly than other aspects of Unity. Unity will make development much ...


0

You need to transform the world space rotation vector to model space before applying the rotation. Vectors are transformed with inverse transpose of the matrix, i.e. v'=transpose(inverse(M))*v Because models generally define model->world matrix you need to invert this to get world->model matrix. So you need to calculate v' = ...


0

If you're using velocities for this, the "jump distance" will be handled automatically. The distance on the X axis traveled during the jump is the product of the time in the air, and the X axis velocity. Say your jump takes one second to complete. If your character is traveling at 10 units per second on the X axis, during that one second jump, they will have ...


0

I would recommend looking at TheChernoProject's Java 2D Game Development series. It is the place where I learn't Java and how games work. I think episode 50 has collision detection (Correct me if I am wrong).


0

I'm not quite sure how to do this in standard Java, but in LWJGL I made an extremely simple method to check if the game is paused or not. Also, instead of having the gamePaused as a boolean it could be an enum. while(Keyboard.next()){ if(Keyboard.getEventKeyState()){ switch(Keyboard.getEventKey()){ case Keyboard.KEY_P: ...


0

You're monster locations are based on a random number: monster.setPositionXY((r.nextInt((int) width)), (r.nextInt((int) height))); You initialize width and height with: width = Gdx.graphics.getWidth(); height = Gdx.graphics.getHeight(); So your monsters will be placed on a random location in screen coordinates. Now I'm not sure about your drawing code ...


0

The SpriteBatch has its own internal camera. Are you also setting the batcher to use the camera's combined projection matrix by calling: batchM.setProjectionMatrix(camera.combined); The problems you could be experiencing, could perhaps be explained by the fact that collisions only appear to be happening on screen, but actually aren't as the map ...


0

You should definitively use a quadtree as Hjorthenify suggest. see: handling collision detection with a quadtree At each frame you may reconstruct your quadtree and then for each collideable entity you retrieve the entities contained (or intersected) in the same area (NE, NW, SE, SW). For exemple : public void checkCollision(Entity e, ...


0

A better way for checking collision two objects is. Object1.PositionX + Object1.Width > Object2.PositionX AND Object1.PositionX < Object2.PositionX + Object2.Width AND Object1.PositionY + Object1.Height > Object2.PositionY AND Object1.PositionY < Object2.PositionX + ...


0

thanks for the answer, I'm sure it would have worked perfectly. however as i was implementing it i came across a Bullet Physics built in function. BtRayCastVehicle has vehicle.getForwardVector() thanks for your help in this matter


0

Give the player a number in their class called hitCountdown or something. Every time they are hit, set that number to the amount of time you want to give the player to escape. Then, where you update the player, decrement the countdown if(hitCountdown > 0) hitCountdown--; Now, when you hit the player and damage him, write this: if(a.overlaps(b)) { ...


0

If you want the ray the vehicle is currently moving upon, you want the difference between the current position and a previous position, then normalize it for the direction of the ray (the start of the ray being the current position). Alternately, you can make a normalized copy of the velocity vector for the direction with and current position as the start of ...


0

I think that a entity would register a listener with whatever was firing the events that entity wanted (much the way you register event listeners to swing components). The entity that was firing events would just make a ArrayList or similar of all the listeners registered to it and whenever it wanted to fire events, it would just iterate through the list ...


1

To get the rotated sprites coordinate simply call the getVertices() method. For example: sprite.getVertices()[SpriteBatch.X2] Gets you the X coordinates of the top left corner. The same call but replacing X<number> with Y<number> gets you the Y coordinate. The corner numbers go like this: 2-3 | | 1-4


0

Container.add doesn't stack components on top of each other -- it appends them according to the installed LayoutManager. Have a look at JLayeredPane instead to achieve the effect you're looking for. But also consider just drawing everything in the Canvas directly (first the background, then the foreground) to avoid the whole Swing kitchen sink.


1

Don,t do any thing just set the scale of the font and it will work for all type of device font.setScale( .9f,.9f);


1

You should use BitmapFont.drawWrapped. public BitmapFont.TextBounds drawWrapped(Batch batch, java.lang.CharSequence str, float x, float y, float wrapWidth) All you need to do is set the wrapWidth variable as ...


0

Write multiline text in LibGdx To write a multiline text with bitmapFont just use this following code- String completeText= "In this text there are multi lines\n.To write this race in your game \n you have to write in proper manner. \nYou have to make the text look better ."; font.drawMultiLine( ...


0

No need to take an extra class for Input just write the following code in render method :- if (Gdx.input.isTouched()) { Rectangle touchRectangle = new Rectangle(Gdx.input.getX( ), Gdx.graphics.getHeight() - Gdx.input.getY( ), 10, 10); //just check if your finger overlaps on your ...


0

initialScale looks like a constant used to scale everything in the game. zoom function calculates originalDistance / currentDistance value, applies it to Camera and prints it out. It's hard to tell more without seeing other affected code.


0

Invalidated by asker If you don't mind to use the same Block over and over again, simply do a mapping Integer→Block. Answer starts here Otherwise, you could use some kind of factory-pattern. You store a mapping Integer→BlockFactory, where BlockFactory is an instance of the Factpry corresponding Block. You then have a newInstance(/*params*/) method ...


2

Here is my two cents: All the work can be found on here too so you can run it and see how it works http://ideone.com/xKWAip Separate it into pieces and you can see how it'll work with a wee access expression after flattening the initial map array. Here is what I used to generate your map (at the moment it's square only but as long as your width and length ...


-1

Turns out if you want to render only colour, but not texture you have to disable GL_TEXTURE_2D


1

In java you can use an RGBImageFilter and a FilteredImageSource to change the individual pixels of an image before you draw it. Image screen = //render screen to image if(timeSinseStartWarp>0){ ImageFilter effectFilter = new Warpfilter(timeSinseStart); screen = createImage(new FilteredImageSource(screen.getSource, effectFilter)); }


2

You're on the right track. Not only do you have to divide the window's width and height in half, but you also have to divide the image's dimensions in half. Pseudocode would resemble something like this: // Center image in middle of screen. image.setCoordinates((screenWidth / 2) - (image.Width / 2)), ((screenHeight / 2) - (image.Height / 2))


2

Note that even though your chunkArray instances are all supposed to cover different areas of your world, their indices still all range from 0 to Chunk.chunkWidth and 0 to Chunk.chunkHeight respectively. Therefore, you should make sure that whenever you access chunkArray the x- and y- indices do not go out of these ranges. The easiest way to make sure they ...


0

I think of having one class for wolves and sheep that has a boolean isWolf; and when it is clicked it calls animate() that is something like this: public void animate(){ if (isWolf) { //play wolf animation } else{ //play sheep animation } }


4

You should consider using a plain 2d-array or alternatively an array of rooms, where each room is a 2d-array or a grid. A grid would looks something like this: The player is the yellow dot and the blocks are the green ones. if the player is the light gray square, you only need to check for blocks that around that square area. This saves you the time of ...


2

For your collision I would merge adjacent colliding tiles together into one big collision box instead of iterating over every single tile and checking their individual collision. Also I think that a quadtree would work much better than your current approach with a HashMap as it splits your gameworld up in sections and make it easy to delete a section of ...


1

The formula for reflecting an incoming vector v across a unit normal n into an outgoing vector v' is v' = v - 2*dot(v,n)*n You can determine the normal n from normalizing the difference of the collision point and the center of the circle. See the question on How to get a reflection vector? over on Math.SX for more elaborate derivations.


1

Since Unity 4.2 there is a class called Androidjavaproxy which can do exactly what you are looking for. This class can implements any Java interface in Unity.


1

You're not setting the projection matrix correctly. At the time you call glOrtho() you probably want to have the GL_PROJECTION matrix mode enabled. Something like that // set projection matrix GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, 1920, 1080, 0, 1, -1); // set modelview matrix to identity ...


1

I have no idea about how JSON of the libGDX parser works, but from what I can see, only keys with a value of 0 were removed. So in your code, if you cannot read the value from the JSON, put 0 as the default one. Also, you can play with the JSON parser to have a better print if you want: http://stackoverflow.com/questions/23401431/libgdx-json-parsing


1

Long term it might be better to create either monster classes that all inherit from a single monster class that contains all methods you need. Then each class can simply override these methods (make them abstract). That will be more scalable. A second good method is to create just 1 monster class and put the variables that monsters use in there (in this case ...


0

The problem was that libgdx has the origin (0,0) in the bottom left corner, but the mouse movement from the InputProcessor has (0,0) in the top left. What I had to do was adjust the mouse y position so that its (0,0) was the bottom left. I did this with: mouseX = screenX; mouseY = Game.HEIGHT - screenY; This will give the player coordinates and mouse ...


1

The only potential harm is to your power consumption, so don't do this on mobile devices. Conversely, quite a few embedded systems spend their entire lives in a loop waiting for things to happen. It used to be entirely normal to simply render game frames as fast as possible, sometimes without even a timer to compensate gameplay for different CPU speeds. ...


0

Currently there is no way to set the position of a TiledMap. All you can do is move the camera to make it seem as though the map is moving. To do this you would have to create your own rendering code that allows for drawing position input. A workaround that you could try would be making the map twice in Tiled (i.e. in one tmx file, have the map repeat once, ...


0

There is also a Vector3D class in Apache Commons Math.


1

I want to say, one of the other answers at the time of writing are suggesting "hard-coding" these events in your language. An alternative approach that can be pretty powerful is using an external format like XML, or a DSL (this is somewhat similar to the script binding approach) to define these events. Then you can easily an editor that outputs it. An ...


0

First, inverse the player position and the mouse position. This way, you will have the real angle from the player to the mouse, and not the opposite. Second, atan2 takes the y difference as the first argument, and the x difference as the second. That is probably why your code looks like it fails. Your code should look like this with the 2 corrections I ...


4

This is actually quite well-detailed at this page. Please note that I am going to detail the common protocol introduced in version 1.7. Additionally, a new protocol was introduced in 1.9pre4 that contains additional information not found in the previous protocol. Let me detail how to get the basic server information in 1.7+: Send a "handshake" packet with ...


0

Try multiplying the y value with -1. And make sure to convert the mouse and playercoordinates to the world coordinates. I had this exact problem yesterday. It has to do with wrong conversion - think about the two different coordinate-systems (Viewport- and World-coordinates)


0

Try using different math techniques for the rotation: Instead of degrees, try using Quaternions. It's the most used rotation technique for 3D objects in professional engines, because degrees don't work as well in 3D. There's more on Wikipedia and I found some Libgdx code. I have more materials, but I can't include them due to my low reputation, but you can ...


0

For 2 and 3 I would try to multiply like so: Scaling = 1.2f; If(Gdx.input.getAcceleratorY() < 5){ Velocity.y = (Gdx.input.getAcceleratorY()*scaling)*(-1); }else if(Gdx.input.getAcceleratorY() >= 5) Velocity.y = Gdx.input.getAcceleratorY()*scaling; } Try different values for scaling (probably has to be greater than 1). This should result in a ...


3

A common way to implement states and branching in a quest is through quest variables. I have witnessed this technique in many RPG titles from companies like Bioware or Bethesda. This is also what I am doing in my current project, and so far it works really well. Just add a script binding which allows scripts to store values in variables and later retrieve ...


1

You shouldn't have jittery movement / gameplay There are two ways that you can implement game logic - tied to a real time, or tied to the number of "turns"/processing steps. If some thingy in your game is moving leftwards, will it's motion be different if your stepLogic() was called 100 instead of 50 times? If your code treats the elapsed time explicitly ...


-1

I'm not exactly sure if this would fit in with JavaScript, I'm always on C++ so there will be differences. Since it's a quest system then I'll just assume it's a RPG and give an answer with that theme. quest: "press A or B" Rewards: A-100 gold; B- 200 gold The scenario now has 2 outcomes, pressing A get's you into branch 1 while pressing B get's you into ...


-1

Actually I think your question is first too broad, so is hard to provide any valuable feedback, and second primarily opinion based. Still, I will pitch my ball. Are you familiar with Formal Grammars in the context of computer science? If you organize terminal symbols as missions or objectives, non-terminal symbols as decisions and production rules as ...


30

It will cause one CPU core to always run on 100%. This usually doesn't cause any harm to the system. CPUs are designed to run on 100% for hours. But on a mobile device it will drain the battery quickly and heat up the device, which will likely cost you about a stars in your store ratings. On a desktop computer this is less of a problem, but it will consume ...



Top 50 recent answers are included