Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (488)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Games Center / Android Showcase / Re: [Android + PC] Word Slide - my action word game on: 2013-04-17 04:46:07
Don't worry just post your games.

But why mad emoticon? Clueless
Just for fun. :p I didn't think anyone noticed topic emoticons, though.
2  Game Development / Shared Code / libGDX: Draw a wavy background on: 2013-04-17 04:44:02
Here is code to make a static picture a wavy background.

A video of what I mean:
http://www.youtube.com/watch?v=HmnEnl0_mr4MmB9b5njVbA

I don't know if there's a better name for it, but basically, it's an effect used in various old video games. The effect worked either scanline based if the hardware supported it (e.g. Game Boy) or simply by sliding the tile rows back and forth. It was often used in lava scenes (to show heat) or underwater scenes.

I wanted to use that effect in my game, so I came up with this code. I have a small feeling that this effect is actually really easy to code, but I was a bit proud when I did it. :p It may be useful to someone, so I'm sharing it.

Usage:
1. Instantiate the BGWave with the file name of the background pic you want to wave (pic should be close to the same resolution as the screen)
2. update() every frame.
3. render() every draw.
4. Remember to dispose() the background texture when you're finished with it.

You may change the field variables to tweak the wave to your liking. Here is a picture describing what the field variables do:



The code itself:

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  
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;

public class BGWave {

   //The background texture
  Texture bg;
   
   //the screen resolution. Update this every frame if you allow screen resizing
  int hres = 640;
   int vres = 480;
   
   //the number of segments on the screen. The higher the number, the better quality
  //the wave looks, but the more polys drawn. Max value is the vertical screen resolution.
  int segments = 32;
   
   //distance wave will travel (be pushed) left/right
  float cycstrength = 16;
   
   //number of complete wave cycles on screen
  float numcycles = 2;
   
   //speed wave will cycle
  float cyclespeed = 1/numcycles;
   
   //the current position of the wave cycle
  float cycoffset = 0;
   
   
   /** Creates the wave background, loading the background texture into memory */
   BGWave(String filename) {
      bg = new Texture(Gdx.files.internal(filename));
   }
   
   
   /** Update the wave by increasing the position of the wave cycle by the speed */
   void update() {
      //make sure you update the resolution (hres/vres) every frame
     // if you expect the screen to be resized
     cycoffset += cyclespeed;
   }
   
   /** Render the wavy background */
   void render() {
     
      //scale the image so that the background image touches the window with no black borders
     float bgscale = hres/(float)bg.getWidth();
      float temp = vres/(float)bg.getHeight();
      if (temp > bgscale) bgscale = temp;
     
      //For reference, here's how you'd draw the background normally, no wave
     /*
      batch.draw(bg,
            GameMain.hres/2-(bg.getWidth()*bgscale)/2,
            GameMain.vres/2-(bg.getHeight()*bgscale)/2,
            bg.getWidth()*bgscale,
            bg.getHeight()*bgscale);
      */

     
      //size of segment on screen
     float segmentSize = vres/(float)segments;
      //size of segment in the picture to draw
     float picSegSize = (segmentSize/bgscale);
      float picYBorder = ((((bg.getHeight()*bgscale)-vres)/2)/bgscale)*1.5f;
     
     
      for (int i = 0; i < segments; i++) {
         batch.draw(bg,
               hres/2-(bg.getWidth()*bgscale)/2 + (pos(i*segmentSize)), //x
              i*segmentSize,                                           //y
              bg.getWidth()*bgscale,                                   //width
              segmentSize,                                             //height
             
               0,                                                       //picture x
              (int) (bg.getHeight()-picYBorder-(picSegSize*i)-picSegSize), //pic y
              bg.getWidth(),                                           //pic wid
              (int)picSegSize,                                         //pic hei
              false,false);
      }
     
   }
   
   /** returns the amount the wave should be pushed left/right in the given position */
   float pos(float num) {
      num += cycoffset;
      return (float) (Math.sin(num*(Math.PI*2/vres)*numcycles)) * cycstrength;
   }

}


Enjoy! Use it as you like.

Room for improvement:
- don't use quads for each segment, use triangles to make parallelograms (it still looks good with quads, though).
3  Games Center / Android Showcase / [Android + PC] Word Slide - my action word game on: 2013-04-17 03:02:22
Slide the tiles and make as many four letter words as you can before the time expires. It's a simple game that's hard to master, but you will quickly be making words like a pro!

Not including the game framework I've created for myself, I completed this in 3 months (the amount of time actually spent on the game was more like 2-3 weeks total). It's my first ever released project, so I'm pretty psyched about it. :p

Uses libGDX.

Android version (free):
http://play.google.com/store/apps/details?id=com.dlesoft.wordslide

PC version:
http://www.mediafire.com/download.php?vdo8n5e7asu8qdc

Video: http://www.youtube.com/watch?v=2E0yGlJ0Zj4

Screenshots:



(I feel a bit bad for registering and just posting my game like this, but after lurking here for a bit, I found out this forum is actually pretty awesome. haha. So I look forward to being here for a long time.)
4  Discussions / General Discussions / Re: Registration Activation Quiz on: 2013-04-17 02:24:10
Despite the complaint, I actually think the current solution is not bad. I mean, most people are probably going to use the site in the middle of coding, anyway. I'm likely in an extremely small group that mostly browses the web on the phone.
5  Discussions / General Discussions / Re: Registration Activation Quiz on: 2013-04-17 01:26:26
I was annoyed with the activation quiz because I was registering on my phone, but today I finally remembered to register while at the same time being on the computer. So I did a simple copy/paste of the code and everything went smoothly.

(Also, yay first post!)
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

TehJavaDev (17 views)
2014-08-28 18:26:30

CopyableCougar4 (26 views)
2014-08-22 19:31:30

atombrot (39 views)
2014-08-19 09:29:53

Tekkerue (36 views)
2014-08-16 06:45:27

Tekkerue (33 views)
2014-08-16 06:22:17

Tekkerue (22 views)
2014-08-16 06:20:21

Tekkerue (33 views)
2014-08-16 06:12:11

Rayexar (68 views)
2014-08-11 02:49:23

BurntPizza (45 views)
2014-08-09 21:09:32

BurntPizza (36 views)
2014-08-08 02:01:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!