Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (576)
games submitted by our members
Games in WIP (497)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2 3 ... 10
 1 
 on: 2014-04-16 07:40:38 
Started by ags1 - Last post by Roquen
Where's the optimization?  This design needlessly (as described) slows things down.

 2 
 on: 2014-04-16 06:59:53 
Started by 04hockey - Last post by Gibbo3771
1366x768 is the new 1024x768.

This practically every sub £1000 laptop has this resolution, a few below this price have 1920x1080 but they are usually pretty shit. With the screen being the selling point and the rest of it men.

 3 
 on: 2014-04-16 06:58:40 
Started by Nausica - Last post by trollwarrior1
When sending tex coords, instead of sprite_x/texture.width, put this: 1f*(sprite_x/texture.width)

 4 
 on: 2014-04-16 06:55:03 
Started by Atheistzilla - Last post by trollwarrior1
Not really.

Not with libgdx.. At least performance wise. The way he did it is he took 4 gray colors (0, 85, 170, 255) and when rendering he would assign each of these colors a color he wanted with code.

Have you watched vanzeben's tutorials? I'm pretty sure he explains just that method.
https://www.youtube.com/watch?v=VE7ezYCTPe4

 5 
 on: 2014-04-16 06:49:49 
Started by SwordsMiner - Last post by trollwarrior1
You might need to be doing x-camera.x,y-camera.y instead of addition.

 6 
 on: 2014-04-16 06:47:09 
Started by SwordsMiner - Last post by HeroesGraveDev
my program has an issue like that when the window is different size than the view port, the drawing is scaled up and down nicely, but the mouse co-ords are still relative to the physical screen resolution.

Try calling glViewport with the window size.

 7 
 on: 2014-04-16 06:45:34 
Started by 04hockey - Last post by HeroesGraveDev
1366x768 is the new 1024x768.

 8 
 on: 2014-04-16 06:13:29 
Started by SwordsMiner - Last post by Jimmt
Maybe he means in-game units?

 9 
 on: 2014-04-16 05:56:45 
Started by Doubstract - Last post by Drenius
But it is at least in misc topics.
Not helpful at all sorry, but seriously, wrong forum.

 10 
 on: 2014-04-16 05:50:31 
Started by Nausica - Last post by Nausica
Hello. I have recently been trying to create a simple program to display an animated image as practice with getting used to using textures in LWJGL (I only have experience using the animation functions in Allegro). I cannot successfully crop my image correctly. I understand that I load the texture once and crop from that, but my code does not crop the actual image. Instead, it copies and tiles the image. Also, I wish to crop from a specific location on the image, but I cannot figure out how to do that either, as my method does not seem to work.

Here is my code for drawing the sprite:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
public void draw(){
      texture.bind();
      glBegin(GL_QUADS);
         glTexCoord2f(frameX/imageWidth,frameY/imageHeight);            
            glVertex2i(x, y);
         glTexCoord2f((float)(frameX + spriteWidth)/imageWidth,frameY/imageHeight);  
            glVertex2i(x + width, y);
         glTexCoord2f((float)(frameX + spriteWidth)/imageWidth,(float)(frameY + spriteHeight)/imageHeight);
            glVertex2i(x + width, y + height);
         glTexCoord2f(frameX/imageWidth,(float)(frameY + spriteHeight)/imageHeight);  
            glVertex2i(x, y + height);
      glEnd();
   }


I have read that you can use pixel coordinates by dividing the location by the Image's width or height where applicable. As I said, it can display the full image, but if I attempt to change the initial coordinate, it either squishes or stretches the image.

Here is where I create the image:

1  
icon = new Sprite(25<<1, 25<<1, 40, 40, 40, 40, "res/smile2.png")


and the constructor:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
public Sprite(int x, int y, int h, int w, int spriteX, int spriteY, String path) {
      super(x, y, h, w);
      this.texture = null;
      sprites.add(this);
      this.path = path;
      this.frame = 0;
      this.key = 0;
      this.spriteWidth = spriteX;
      this.spriteHeight = spriteY;
      loadSprites();
   }


finally, the animation call and the animate() method:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
public void animate(int x_pos, int y_pos, int frame_start, int frame_end, int timeStep, boolean loop){
      if(loop){
         if(frame == frame_end)
            frame = frame_start;
      }
     
      if(frame > frame_end){
         frame = 0;
      }
     
      frameX = x_pos * frame;
      frameY = y_pos;
     
      if(key == timeStep){
         frame++;
         key = 0;
      }
   }


1  
icon.animate(20, 20, 0, 2, 3, false);


There may be simpler way to do these things, but I really want to get the fundamentals of keying and animating things, specifically using LWJGL. Please help.

Pages: [1] 2 3 ... 10
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (12 views)
2014-04-15 18:08:23

BurntPizza (10 views)
2014-04-15 03:46:01

UprightPath (23 views)
2014-04-14 17:39:50

UprightPath (10 views)
2014-04-14 17:35:47

Porlus (27 views)
2014-04-14 15:48:38

tom_mai78101 (49 views)
2014-04-10 04:04:31

BurntPizza (107 views)
2014-04-08 23:06:04

tom_mai78101 (207 views)
2014-04-05 13:34:39

trollwarrior1 (176 views)
2014-04-04 12:06:45

CJLetsGame (182 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!