Show Posts
|
|
Pages: [1] 2
|
|
3
|
Game Development / Newbie & Debugging Questions / Re: Tween functions?
|
on: 2013-05-16 15:10:49
|
|
I always look at the license.
I'm searching for codes that are written and all can use it in the game.
I do not know how to say this.
E.g. when somebody wants to make a website, he looks for written Layouts. And of course to the license. And then the programmer downloads or copy & pastes that layout in the file.
And that's, what I'm searching for. Written tweens. (Why reinvent the wheel)
|
|
|
|
|
7
|
Game Development / Newbie & Debugging Questions / Tween functions?
|
on: 2013-05-16 09:28:36
|
|
Hi,
I want to make tween animations in a game.
E.g. when the player gets a coin, I want to show on the position of the coin the score and then the score is moving up and is going transparent. (Floating score)
I know, there are tween libraries. But I'm searching only for the algorithm. Not only for the floating score.
All the functions the are useful for games.
Another example: The text "Game over" is coming from up to the center of the screen and waiting for 3 seconds and then is moving to the bottom screen.
I can make tween animations myself. But it takes time.
|
|
|
|
|
9
|
Game Development / Newbie & Debugging Questions / LibGDX - StillModel mesh - dispose?
|
on: 2013-05-14 09:05:55
|
Hi, I have 16 Levels. In each level, I have a different 3d environment (mountains, buildings, volcano etc.). Now When I go to Level 2, I don't need anymore the environment of Level 1. How can I now free the memory of this meshes? For example: 1 2
| StillModel mountain; StillModel buildings; |
|
|
|
|
|
14
|
Game Development / Newbie & Debugging Questions / Re: Time based movement / deltaTime / Event Timing ?
|
on: 2013-04-12 16:32:07
|
Here is an example. In my app, there is a red box. It's moving from left to right. The app starts, when you touch the screen. Now, I installed this on my big and small smartphone. I touch the both devices at the same time. And now I see, that the red box on my smaller smartphone touches the right side of the screen first. In my app, there is a ease function from Robert Penner and I added Aspect ratio. So, first the images: (This is my libgdx.png file)  (this is, where the red box starts)  (and this is, where the red box touches the right side)  And this is the code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
| package com.me.mygdxgame;
import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Camera; import com.badlogic.gdx.graphics.GL10; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture.TextureFilter; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2;
public class MyGdxGame implements ApplicationListener { private static final int VIRTUAL_WIDTH = 800; private static final int VIRTUAL_HEIGHT = 480; private static final float ASPECT_RATIO = (float)VIRTUAL_WIDTH/(float)VIRTUAL_HEIGHT; private Rectangle viewport; private OrthographicCamera camera; private SpriteBatch batch; private Texture texture; private Sprite sprite; private float x = 0f; private float y = 0f; private boolean start = false; private float diff = 200f;
private float minTime = 0; private float maxTime = 770f; private float iEaseOut = 0; private float zTime = 0; @Override public void create() {
camera = new OrthographicCamera(VIRTUAL_WIDTH, VIRTUAL_HEIGHT); batch = new SpriteBatch(); texture = new Texture(Gdx.files.internal("data/libgdx.png")); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); TextureRegion region = new TextureRegion(texture, 2, 2, 32, 32); sprite = new Sprite(region); }
@Override public void dispose() { batch.dispose(); texture.dispose(); }
@Override public void render() { float deltaTime = Gdx.graphics.getDeltaTime(); if (Gdx.input.isTouched()) { start = true; } if (start) {
if (iEaseOut < diff) { zTime = expoEaseOut(iEaseOut, minTime, maxTime, diff);
float deltaAdd = zTime*deltaTime; zTime += deltaAdd; x = zTime;
iEaseOut++; } else { start = false; } } System.out.println(Gdx.graphics.getDeltaTime()); Gdx.gl.glClearColor(1, 1, 1, 1); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); camera.update(); Gdx.gl.glViewport((int) viewport.x, (int) viewport.y, (int) viewport.width, (int) viewport.height); batch.setProjectionMatrix(camera.combined); batch.begin(); sprite.setPosition(x-VIRTUAL_WIDTH/2, y); sprite.draw(batch); batch.end(); } public static float expoEaseOut(float t,float b , float c, float d) { return (t==d) ? b+c : c * (-(float)Math.pow(2, -10 * t/d) + 1) + b; }
@Override public void resize(int width, int height) { float aspectRatio = (float)width/(float)height; float scale = 1f; Vector2 crop = new Vector2(0f, 0f); if(aspectRatio > ASPECT_RATIO) { scale = (float)height/(float)VIRTUAL_HEIGHT; crop.x = (width - VIRTUAL_WIDTH*scale)/2f; } else if(aspectRatio < ASPECT_RATIO) { scale = (float)width/(float)VIRTUAL_WIDTH; crop.y = (height - VIRTUAL_HEIGHT*scale)/2f; } else { scale = (float)width/(float)VIRTUAL_WIDTH; }
float w = (float)VIRTUAL_WIDTH*scale; float h = (float)VIRTUAL_HEIGHT*scale; viewport = new Rectangle(crop.x, crop.y, w, h); }
@Override public void pause() { }
@Override public void resume() { } } |
|
|
|
|
|
16
|
Game Development / Newbie & Debugging Questions / Time based movement / deltaTime / Event Timing ?
|
on: 2013-04-12 09:14:39
|
Hi, I'm really confused. The app is faster or slower on some devices. I had some small problems with libgdx. BUT this is the biggest problem that I've had. First I thought I understood deltaTime. But that is not so. Why is that so hard. I made a small program, where is a 3d cube is moving from left to right. And then the 3d cube is moving backwards. I've tried so many things. NOTHING WORKS. I also added the deltaTime (test += steps*deltaTime) to the movement. Nothing helps. On my smaller smartphone the movement is faster. I don't know what to do. On my bigger smartphone is it slower. I have read all of this. (some things I did not understand): http://gafferongames.com/game-physics/fix-your-timestep/http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=1845&p=10046&hilit=step+deltatime#p10046http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=4185&p=20139&hilit=deltaTime#p20139Has somebody not a great solution for this. How can I do it, that the render() renders at the same speed on all devices? I read about accumulate or something like that. Is this the answer? Info: I'm not using box2d. Has anybody solved this problem. It would be great, when somebody can post a working example code. My program looks a little bit like this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| public class ObjectScreen implements Screen { Game game;
public ObjectScreen (Game game) { this.game = game; cam = new PerspectiveCamera(45, VIRTUAL_WIDTH, VIRTUAL_HEIGHT); ... } ...
@Override public void render (float delta) { update(delta); draw(delta); }
public void update (float deltaTime) { }
public void draw (float deltaTime) {
GL10 gl = Gdx.graphics.getGL10();
gl.glClearColor(0.0f, 0.0f, 0.0f, 1);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); ... ... } } |
Thank You!
|
|
|
|
|
18
|
Game Development / Newbie & Debugging Questions / Re: LibGDX - deltatime?
|
on: 2013-04-06 20:45:05
|
Yes, I know this, but is it not possible to do this without to add the deltaTime to the movemet variable? My project looks like this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| public class ObjectScreen implements Screen { Game game;
public ObjectScreen (Game game) { this.game = game; cam = new PerspectiveCamera(45, VIRTUAL_WIDTH, VIRTUAL_HEIGHT); ... } ...
@Override public void render (float delta) { update(delta); draw(delta); }
public void update (float deltaTime) { }
public void draw (float deltaTime) { if (deltaTime > 0.1f) deltaTime = 0.1f;
GL10 gl = Gdx.graphics.getGL10();
gl.glClearColor(0.0f, 0.0f, 0.0f, 1);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); ... ... } } |
|
|
|
|
|
20
|
Game Development / Newbie & Debugging Questions / LibGDX - deltatime?
|
on: 2013-04-06 20:28:27
|
3d Object moving on my second phone is faster. I tried this here: 1
| if (deltaTime > 0.1f) deltaTime = 0.1f; |
But this don't works. How can I do it, that the render() has the same speed on all phones? I thought, that LibGDX regulates the deltatime self.
|
|
|
|
|
21
|
Game Development / Newbie & Debugging Questions / Opengl - Light looks different?
|
on: 2013-04-06 15:31:06
|
Hi, I'm programming with LibGDX. I added this code: 1 2 3 4
| float lightColor1[] = {1.0f, 1.0f, 1.0f, 1.0f}; float lightPos1[] = {-1.0f, 0.5f, 0.5f, 0.0f}; gl.glLightfv(GL10.GL_LIGHT1, GL10.GL_DIFFUSE, lightColor1, 0); gl.glLightfv(GL10.GL_LIGHT1, GL10.GL_POSITION, lightPos1, 0); |
I have two different smartphones. The Light looks different on this two smartphones. I don't know why? On the first smartphone the light is weak and on the second smartphone the light is bright. EDIT: OK. Now I programmed this: 1 2 3 4 5 6 7 8 9 10 11
| float ambientLight[] = { 1f, 1f, 1f, 1.0f }; float diffuseLight[] = { 1f, 1f, 1f, 1.0f }; float specularLight[] = { 1f, 1f, 1f, 1.0f }; float position[] = { 0f,0f, 5.0f, 1.0f };
gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_AMBIENT, ambientLight, 0); gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, diffuseLight, 0); gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_SPECULAR, specularLight, 0); gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, position, 0); |
It's now a little bit better, but on the small smartphone the texture looks brighter.
|
|
|
|
|
22
|
Game Development / Newbie & Debugging Questions / Re: LibGDX - Camera Coordinate To Screen Coordinate?
|
on: 2013-03-29 14:49:58
|
I added the perspective camera like this: 1
| camera = new PerspectiveCamera(67, VIRTUAL_WIDTH, VIRTUAL_HEIGHT); |
gluPerspective is the same, right? OK. I try to explain. e.g. The sprite is moving from left to right. When I now 1
| System.out.println(sprite.x+" | "+sprite.y) |
I get this e.g. x:50, y:100 or x:55, y100 or x:500, y:100 etc. The (0,0) is left bottom! Now I don't know how move the 3d object at this positions? This is not working: 1
| Gdx.gl10.glTranslatef(sprite.x, srite.y, -35.0f); |
For e.g. When I do this, 1
| Gdx.gl10.glTranslatef(100f, 0.0f, -35.0f); |
I don't see the 3d object on the screen:
|
|
|
|
|
23
|
Game Development / Newbie & Debugging Questions / LibGDX - Camera Coordinate To Screen Coordinate?
|
on: 2013-03-29 13:52:24
|
Hi, I made a sprite, that is moving on the screen. The sprite moves from left screen to the right screen. Now, I will hide the sprite and I will add a 3d Object on the sprites position. The problem is now: The width and height of the screen is 800x480. And now I don't know how to move the 3d object? e.g. 1
| Gdx.gl10.glTranslatef(sprite.x, srite.y, -35.0f); |
Must I now cam.project or cam.unproject this? Or what is the right keyword?
|
|
|
|
|
25
|
Game Development / Newbie & Debugging Questions / LibGDX - Get TouchPoint X and Y in Perspective?
|
on: 2013-03-27 17:22:52
|
Hi, I add a perspective camera. 1
| cam = new PerspectiveCamera(45, 480, 320); |
When I try to get the touchpoints with 1
| (Gdx.input.getX(), Gdx.input.getY()) |
I get wrong numbers. My Perspective width is 480. When I touch with my finger the screen (rightmost), I get 1196. This is my screen resolution of my device. EDIT: I also get wrong numbers when I try: 1 2 3 4 5
| private Vector3 touchPoint;
cam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));
System.out.println(touchPoint.x+" | "+touchPoint.y); |
I get something like this with touchpoint.x: -6 to 0.75
|
|
|
|
|
27
|
Game Development / Newbie & Debugging Questions / LibGDX - How change the standard LibGX Project to Perspective Camera?
|
on: 2013-03-27 12:01:40
|
Hi, I generated the simple LibGDX project where you see a LibGDX image. The example is made with 1
| private OrthographicCamera camera; |
How can I change this to Perpective Camera? I want it in Perspective Camera with the same look like in Orthographic Camera. I will add some 3d objects on this image. Like this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| StillModel mesh;
... create()
mesh = ModelLoaderRegistry.loadStillModel(Gdx.files.internal("data/testObject.obj"));
... render()
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
camera.update();
batch.setProjectionMatrix(camera.combined); batch.begin(); sprite.draw(batch); batch.end();
gl.glEnable(GL10.GL_DEPTH_TEST); gl.glEnable(GL10.GL_LIGHTING); gl.glEnable(GL10.GL_COLOR_MATERIAL); gl.glEnable(GL10.GL_TEXTURE_2D);
camera.update(); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity();
gl.glLoadMatrixf(cam.projection.val, 0); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadMatrixf(cam.view.val, 0);
gl.glEnable(GL10.GL_LIGHT0); gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, lightColor, 0); gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, lightPosition, 0);
gl.glRotatef(angleY, 0, 1, 0); gl.glRotatef(angleX, 1, 0, 0); mesh.render(); ... |
Has someone an Idea?
|
|
|
|
|
28
|
Discussions / General Discussions / Re: In-App Purchase
|
on: 2013-03-23 17:44:57
|
Wow! Thanks! About the game. I only made one level and the train movements. Before I write the whole game I wanted to inform me what I can do. I played Subway Surfers. Is well done. Now I will take a pencil and a sheet of paper and make a game concept. 
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|