Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (800)
Games in Android Showcase (237)
games submitted by our members
Games in WIP (867)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  About "Basic animation in LWJGL"  (Read 1857 times)
0 Members and 1 Guest are viewing this topic.
Offline ipe369

Junior Devvie

Medals: 3
Exp: 3 years

« Posted 2014-06-19 11:01:38 »


I wasn't sure whether to create a new topic for this - I know it's nice to have separate topics for different things despite them being related - but I'm asking a question based of someone's response to another question.

In AppleSauce's thread, he asked about how to do basic 2D animation in LWJGL. Now, in the past, I've always done this by having 1 texture (A strip) and timing how much time has gone past inbetween each frame. when this reaches the right amount, I change the 'viewing window' or the texture coordinates to the next frame - and I assumed this was standard.

But Drenius put this:
If you think you are fine, ok.
Having a timer for every single texture in the program is a waste.
Make it jump to the frame it has to be in when it is rendered when it is rendered.

Maybe I'm misunderstanding what was said, but from what I understand the method I'm using is a waste as I use multiple timers for each animation.

I don't understand what I should do instead - "Make it jump to the frame it has to be in when it is rendered" ??

Sorry, I'm at a loss, can anyone help?Tongue
Offline trollwarrior1
« Reply #1 - Posted 2014-06-19 11:03:54 »

Can you show us how you render your sprites?
Offline BurntPizza

« JGO Bitwise Duke »

Medals: 486
Exp: 7 years

« Reply #2 - Posted 2014-06-19 11:07:44 »

This really should be in the same thread, as it is simply a reply to a comment...

I believe he means something like this:

render() {

Where getFrameForTime() takes frame duration and looping information into account to spit out what frame the animation is currently on, no timer required.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Drenius
« Reply #3 - Posted 2014-06-19 14:06:26 »

I placed the second "when it is rendered" for a reason, also the second "when" was itallic for a reason.
If you do not render a texture within a time span, you must not update it.
You should just save when the last frame change took place and once you render the texture again, you can check how many frames must have passed since then and set it to that frame.
Offline ipe369

Junior Devvie

Medals: 3
Exp: 3 years

« Reply #4 - Posted 2014-06-19 14:43:26 »

But the location that the sprite needs to be could change every frame, isn't it less complex to just render it each frame? Especially with a moving camera - or should I be keeping track or if I need to redraw it?
Pages: [1]
  ignore  |  Print  

Riven (346 views)
2019-09-04 15:33:17

hadezbladez (5128 views)
2018-11-16 13:46:03

hadezbladez (2010 views)
2018-11-16 13:41:33

hadezbladez (5397 views)
2018-11-16 13:35:35

hadezbladez (1118 views)
2018-11-16 13:32:03

EgonOlsen (4536 views)
2018-06-10 19:43:48

EgonOlsen (5393 views)
2018-06-10 19:43:44

EgonOlsen (3081 views)
2018-06-10 19:43:20

DesertCoockie (3975 views)
2018-05-13 18:23:11

nelsongames (4526 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08 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‑
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!