Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (492)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
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 4 ... 8
  ignore  |  Print  
  LodeScape RPG  (Read 27504 times)
0 Members and 1 Guest are viewing this topic.
Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #30 - Posted 2013-03-28 15:35:42 »

Sure! It turned out to be pretty simple using libgdx. Ill just go ahead and share the whole class:
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  
package com.reed.birdseye;

import java.util.Random;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class Mob {
   // Class defines a randomly moving "mob" (animal, monster, etc)

   final int distanceFromMob = 100;
   Random r = new Random();
    //defines the x and y position where the "mob" is
  int x = 500;
   int y = 500; // set to random

   int direction = r.nextInt(5) + 1; // 0 = up, 1 = down, 2 = left, 3 = right,
                             // 4 = no movement
  float mobTime = r.nextInt(3) + 1;
   // defines time left for movement - set to random int below 3 (will move around at MOST for three seconds then switch directions)
  final int speed = 1;

   
    //draws the mob, and the text
  void draw(SpriteBatch batch, BitmapFont font) {
      batch.draw(Assets.creeper, Level.levelX + x, Level.levelY + y);
      if (closeEnough())
         font.draw(batch, "I'm a mob", 50, 100);
   }
    //Moves the mov in whatever direction it is set at
  void movement() {
      // constantly decrease the mobTime
     mobTime -= Gdx.graphics.getDeltaTime();
      if (direction == 0 && mobTime > 0) {
         y += speed;//increasing speeds should be changed to some frame independent method using Gdx.graphics.getDeltaTime() ....
     } else if (direction == 1 && mobTime > 0) {
         y -= speed;
      } else if (direction == 2 && mobTime > 0) {
         x -= speed;
      } else if (direction == 3 && mobTime > 0) {
         x += speed;
      } else if (direction == 4 && mobTime > 0) {
         // 4 means no movement
     } else {
        //Reset the values for a new direction and duration
        mobTime = r.nextInt(3) + 1;
         direction = r.nextInt(5) + 1;
      }
   }

    //limits the areas the mob can go so it doesn't wander endlessly off the screen
  void boundingArea(int xCord, int yCord, int width, int height) {
      if (x > xCord + width)
         direction = 2;
      if (x < xCord)
         direction = 3;
      if (y > yCord + height)
         direction = 1;
      if (y < yCord)
         direction = 0;
   }
    //detects how close you are to the mob these variables may be a little hard to understand but all it is, is a distance formula
  boolean closeEnough() {
      return (Math.sqrt((Level.levelX + x - Level.middleX)
            * (Level.levelX + x - Level.middleX)
            + (Level.levelY + y - Level.middleY)
            * (Level.levelY + y - Level.middleY)) < distanceFromMob);
   }
}


If you have any questions about this feel free to ask

Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #31 - Posted 2013-03-28 18:42:06 »

Just finished implementing a simple crafting system (not exactly crafting yet but the concept is all there) that is available in the updated download.
This download includes: new Mob ai, crafting menu (can be accesed by pressing z during gameplay), farm and house have been excluded from this update until some small bugs are fixed.
here is a screenshot of the crafting menu:


The mob is viewable in the bottom left area of the map. Please report any bugs / problems, enjoy!

Download link: http://goo.gl/rf79e

Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #32 - Posted 2013-03-29 18:21:36 »

For everyone who was having trouble with opening this on a Mac I will do little tutorial to help you out.
1. Open up terminal
2. type java -jar (drag the JAR file to the Terminal window)
3. Make sure you have a space between -jar and the file you dragged into the window
4. Press enter and enjoy!

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #33 - Posted 2013-03-30 16:00:58 »

Just spent some time recently to add a new "Mining Robot" which basically goes around collecting a single ore every minute. Eventually you will need to supply it with coal to keep it going but for now it works. Also I added a new iron and copper ore. Copper will be needed to build electronics (such as the mining robot) and iron is used for structures. The top bar of items / amounts has been removed and replaced with a blank bar which eventually will contain tools to use to make a particular task faster / easier. Since there are currently no tools it is blank. You can view your inventory by clicking the box with the slashes in it.
Here is the mining robot and its simple GUI.


At the moment its pretty simple but as I said above it will gain more features soon.
Also here are the new ores and the new Inventory system.

the left ore is copper and the right is iron


Eventually I think I will add pictures to the inventory / robot gui so you know which is which. Here is the updated download: http://goo.gl/RYovl

Offline Apex5

Junior Member


Medals: 1
Projects: 1



« Reply #34 - Posted 2013-03-30 22:20:41 »

Looking great so far Cheesy Do you have any plans to procedurally generate content? (presuming so far you're using a fixed grid owtte).
I always find it hard in rpg projects to keep code as clean as possible X) Good luck!
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
Exp: 3 years



« Reply #35 - Posted 2013-03-30 22:28:35 »

What font is that?
Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #36 - Posted 2013-03-30 22:34:27 »

Looking great so far Cheesy Do you have any plans to procedurally generate content? (presuming so far you're using a fixed grid owtte).
I always find it hard in rpg projects to keep code as clean as possible X) Good luck!

Eventually I do plan on setting up a randomly generated terrain, right now it is not set in a fixed grid however.

Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #37 - Posted 2013-03-30 22:35:10 »

What font is that?

The cooler looking one in the menus? or the one that is drawn when you go over an object?

Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #38 - Posted 2013-04-07 02:51:08 »

Just created and added a super cool tree falling animation made with Spine Cheesy
Click to Play

The animation doesn't completely give it justice so go ahead and download the updated game here: http://goo.gl/f0xAw
If you run out of trees to place just go ahead and click z and place a new tree through the craft menu. If you have any suggestions for more animations to add or anything about the game in general feel free to leave a comment

Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
Exp: 3 years



« Reply #39 - Posted 2013-04-07 03:53:53 »

What font is that?

The cooler looking one in the menus? or the one that is drawn when you go over an object?
argh late reply by me
meant the one in the menus
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #40 - Posted 2013-04-07 04:10:57 »

Cgf locust resistance

Offline matheus23

JGO Kernel


Medals: 106
Projects: 3


You think about my Avatar right now!


« Reply #41 - Posted 2013-04-07 08:25:00 »

Just created and added a super cool tree falling animation made with Spine Cheesy
Click to Play


Ahahaha Cheesy This looks awesome! Smiley
Still needs some art-work on the trunk though Smiley

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline isteinvids

Junior Member


Medals: 1



« Reply #42 - Posted 2013-04-07 10:42:39 »

Try adding infinite terrain, with the background grass texture on repeat, and trees and stuff added randomly on terrain. Besides figuring out an algorithm for random trees, it shouldn't be too hard.
Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #43 - Posted 2013-04-07 12:41:45 »


Ahahaha Cheesy This looks awesome! Smiley
Still needs some art-work on the trunk though Smiley
[/quote]

I did notice after staring at it, that it looks a little awkward  Clueless

Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #44 - Posted 2013-04-07 12:43:15 »

Try adding infinite terrain, with the background grass texture on repeat, and trees and stuff added randomly on terrain. Besides figuring out an algorithm for random trees, it shouldn't be too hard.

That's a goal, but do you have any suggestions on making the unlimited terrain? I really am not sure about that one.... The trees seems easy although detecting for overlapping trees might take some thinking. Also just as a follow up any chance that AI code helped you out?

Offline isteinvids

Junior Member


Medals: 1



« Reply #45 - Posted 2013-04-07 13:28:37 »

Didn't really help cause I don't use libgdx, I personally prefer Slick2d, but it may have been helpful for others xD
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #46 - Posted 2013-04-07 13:50:48 »

Didn't really help cause I don't use libgdx, I personally prefer Slick2d, but it may have been helpful for others xD

The AI part is not really libgdx specific haha Smiley
Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #47 - Posted 2013-04-07 14:00:37 »

Didn't really help cause I don't use libgdx, I personally prefer Slick2d, but it may have been helpful for others xD

Well just check out this article if you are having trouble with deltaTime problems.

Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #48 - Posted 2013-04-07 14:01:55 »

also, @isteinvids do you have any idea on how to get unlimited (background) terrain working? I am trying to find some stuff on the internet but no luck so far.

Offline isteinvids

Junior Member


Medals: 1



« Reply #49 - Posted 2013-04-07 14:05:54 »

You mean the repeated grass?
This could help;
http://gamedev.stackexchange.com/questions/34648/repeat-texture-in-libgdx
Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #50 - Posted 2013-04-07 14:25:11 »


That worked pretty good although still not unlimited (stuck at a fixed amount)

Offline isteinvids

Junior Member


Medals: 1



« Reply #51 - Posted 2013-04-08 13:24:04 »


I did manage to do infinite background texture, it is made with Slick2d, but as long as you can get background texture width and height, it should work c:

Press space to toggle repeated texture, you should understand something if repeated texture is off.

Executable jar: https://dl.dropbox.com/u/52647185/Infinite%20Background.jar

Source code: http://pastebin.java-gaming.org/cb94c832e5b

You're welcome Grin
Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #52 - Posted 2013-04-08 21:18:02 »

I did manage to do infinite background texture, it is made with Slick2d, but as long as you can get background texture width and height, it should work c:

Press space to toggle repeated texture, you should understand something if repeated texture is off.

Executable jar: https://dl.dropbox.com/u/52647185/Infinite%20Background.jar

Source code: http://pastebin.java-gaming.org/cb94c832e5b

You're welcome Grin

Could you give me some insight on the variable names?

Offline isteinvids

Junior Member


Medals: 1



« Reply #53 - Posted 2013-04-08 21:48:02 »

I did manage to do infinite background texture, it is made with Slick2d, but as long as you can get background texture width and height, it should work c:

Press space to toggle repeated texture, you should understand something if repeated texture is off.

Executable jar: https://dl.dropbox.com/u/52647185/Infinite%20Background.jar

Source code: http://pastebin.java-gaming.org/cb94c832e5b

You're welcome Grin

Could you give me some insight on the variable names?

grX and grY are just image width and height,  gX and gY are position of grass texture, and you shouldn't have to use toggleX.

Basically, the texture is in middle, and if it moves exactly it's own width/height, it moves back to it's original place. So, if the image is repeated, it gives the illusion of infinite terrain.
Offline isteinvids

Junior Member


Medals: 1



« Reply #54 - Posted 2013-04-08 21:54:26 »

Btw, if you couldn't tell, I'm really bad at explaining my own code :/
Offline HeroesGraveDev

JGO Kernel


Medals: 246
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #55 - Posted 2013-04-09 08:19:03 »

You got a name yet?

Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #56 - Posted 2013-04-09 10:44:08 »

You got a name yet?
Not yet.... any suggestions for a name?

Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #57 - Posted 2013-04-12 21:37:51 »

@isteinvids I reached my message limit for the day concerning that repeated texture. Do you have an email to talk with?

Offline isteinvids

Junior Member


Medals: 1



« Reply #58 - Posted 2013-04-12 21:42:36 »

@isteinvids I reached my message limit for the day concerning that repeated texture. Do you have an email to talk with?

You got Skype? Mine is emir.rhouni
Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #59 - Posted 2013-04-12 21:47:40 »

Mine is wreed12345 , I couldn't add you when I tried, is yours private or something? Maybe try adding me

Pages: 1 [2] 3 4 ... 8
  ignore  |  Print  
 
 

 

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

The first screenshot will be displayed as a thumbnail.

Nickropheliac (15 views)
2014-08-31 22:59:12

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

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

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

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

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

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

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

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

BurntPizza (49 views)
2014-08-09 21:09:32
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!