Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
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] 2
1  Game Development / Newbie & Debugging Questions / face/turn the character in the direction the mouse is facing? on: 2012-05-09 17:25:46
hello! im working on my first ever game, and i want the player to be able to turn freely by pointing the mouse in a certain direction. I am definately not advanced with java yet, so ignore the dumb questions please  Tongue


another thing im trying to do is have the camera follow the player, so that the player is always in the middle of the screen, unless if there comming to the edge of the map.

any help is much appreciated, thanks!


EDIT: forgot to post any code, whoops

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  
package game;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Rectangle;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.tiled.TiledMap;

public class Play extends BasicGameState{
   
   private Input input;
   
   TiledMap tm;
   int mapHeight, mapWidth;
   float playerX;
   float playerY;
   float playerCenterX;
   float playerCenterY;
   float playerRotation;
   float speed = 0.2f;
   int cameraX = 0;
   int cameraY = 0;
   private Image player;
   static int WIDTH = 800;
   static int HEIGHT = 600;
   Rectangle camera;
   
    public Play(int state){
         
    }
     
    public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
       camera = new Rectangle(0, 0, 800, 600);
      gc.setVSync(true);
      tm = new TiledMap("res/map1.tmx");
      player = new Image("res/character01.png");
      mapWidth = tm.getWidth()*tm.getTileWidth();
      mapHeight = tm.getHeight()*tm.getTileHeight();
      playerX = 400 - player.getWidth() / 2;
       playerY = 300 - player.getHeight() / 2;
    }


    public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
       tm.render(0, 0);
       playerCenterX = playerX + player.getWidth() / 2;
       playerCenterY = playerY + player.getHeight() / 2;
       player.draw(cameraX + playerX, cameraY + playerY);
    }

   public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
       input = gc.getInput();

       if (input.isKeyDown(Input.KEY_W)) {
            playerY -= speed * delta;
       }
       
       if (input.isKeyDown(Input.KEY_A)) {
            playerX -= speed * delta;
       }

       if (input.isKeyDown(Input.KEY_S)) {
            playerY += speed * delta;
       }
         
       if (input.isKeyDown(Input.KEY_D)) {
            playerX += speed * delta;
       }        
   }

   public int getID() {
        return 1;
         
    }
   
}
2  Game Development / Newbie & Debugging Questions / Re: what map format would be best? on: 2012-05-09 01:28:10
1. Use your own! Simply random generate the map, place some random zombies and objects here and there. Put them all in a list, and update and render them.

2. If you use boolean flags in your key listener, your main loop should update the player's location based on which booleans are on. This way you can hold two buttons at the same time.
thanks, i decided to just go with tiled.

i havnt started movement yet, but i read from a couple posts of people having movement problems but i guess ill just have to mess with it myself once i get around to working on movement
3  Game Development / Newbie & Debugging Questions / what map format would be best? on: 2012-05-08 23:18:58
hello all, the style of game im trying to make is a 2d zombie topview game, i just started the project yesterday and am close to finishing up my main menu, then i will be moving on to the actual game, my idea is for players to move there character with wasd, and aim using the mouse, rotating the character based on which direction the mouse is pointed in, the first thing i need to do is load a map, but i havnt decided on a map format yet, i was thinking about using tiled, does anyone know of any other map formats that could be better for what i need?

my other question is how to do free movement, where the player can move freely around the map without just going up, down, left, right.


thanks.
4  Game Development / Newbie & Debugging Questions / Re: 2D game development? on: 2012-04-17 20:42:49
that looks pretty sweet, thanks for the link wook, ill check that out Smiley

and thanks everyone else, ill look into it all
5  Game Development / Newbie & Debugging Questions / 2D game development? on: 2012-04-17 06:37:59
hi guys, i have this dream of making a game like this --->http://www.youtube.com/watch?v=uXU4LxQGVtE&list=UUg2c4yXKqmBSLYQfZ-HHDig&index=1&feature=plcp

have wanted to make one EXACTLY like that, for years now, but i dont know where to start, what libraries, some good 2d java game tutorials? anything helps, thanks.
6  Game Development / Newbie & Debugging Questions / players cant run my client, also need to support linux/mac on: 2012-03-31 23:18:10
alright so, i opened up my game for people to play, i compiled, jar'd, and signed my webclient with jdk1.6.0_17, and people still get some errors, such as it just being a whitescreen, and this error:
1  
2  
3  
4  
5  
6  
Exception in thread "thread applet-client.class-1" java.lang.UnsupportedClassVersionError: sign/signlink : Unsupported major.minor version 51.0
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClassCond(Unknown Source)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at java.security.SecureClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoad

i know what the error is from, they must have a lower JDK then what i compiled with, but i thought jdk 1.6.0_17 was the lowest..

also, i would like my downloadable client to be able to run on linux/mac, if anyone knows the code for that, would be much appreciated.
my current run:
1  
2  
3  
@echo off
java -Xmx512m Jframe 10 0 highmem members 32
pause
7  Discussions / Business and Project Management Discussions / Re: runescape private servers - looking for developer on: 2012-03-20 03:07:25
jagex constantly sends out dmca notices, but they never actually take servers down, you can host offshore and easily do it without risk.

i wasnt trying to make a argument thread about legality, im just looking for a partner, so we can start making money from donations.
8  Discussions / Business and Project Management Discussions / Re: runescape private servers - looking for developer on: 2012-03-19 04:43:06
because i don't feel like making models, maps, objects, etc. With an RSPS, i already have a boatload of them, and there's a good crowed wanting to play RSPS, less time is also needed to develop a good RSPS then a whole entire new game.

there is servers, which make around 30k+ USD per month from donations, they have a 1-2K player base.

much easier/cheaper to advertise.
9  Discussions / Business and Project Management Discussions / Re: runescape private servers - looking for developer on: 2012-03-15 05:23:39
I don't even think on moparscape you can just make a post and say 'DEVELOPER NEEDED', usually 2 to 3 minutes later that threads locked and that poster's bieng watched+moterated..
Because moparscape's going down don't come here and do it  Angry
im not even apart of moparscape, i use rune-server fyi. i am totally unfamiliar with moparscape rules.
10  Discussions / Business and Project Management Discussions / Re: runescape private servers - looking for developer on: 2012-03-15 05:19:31
Well I've programmed rsps for over 4+ years, from 317's to 614's in and out, if you had a Compiling problem yeah, inbox me the problem and I could help you or something.

I came here to get away from all the rsps coding, all that is nothing you've developed or anything you're going to develop with it, I went OFF on moparscape, everything is leeched from Jagex yet people deny it to the max that 'they built it', that's not the case here but, keep it off the forums here pl00x, last thing we need is a 'RuneScape Private Server Section'  Shocked Shocked Shocked
 Cool
i came here instead of the usual forums because most people on there forums are idiots, was hoping to find someone serious here, but meh, guess no ones interested.
11  Discussions / Business and Project Management Discussions / Re: runescape private servers - looking for developer on: 2012-03-15 04:58:41
i'm not looking for someone to code for me, im looking for a teamwork type deal, so that i can get up and running quicker.
12  Discussions / Business and Project Management Discussions / Re: runescape private servers - looking for developer on: 2012-03-15 04:55:54
Dude, PLEASE do not bring Runescape to these forums..
go to moparscape.org.
*Cough* Delta.
this is a java forum, private servers are written in java, I see no reason why I cant post this here.
I'm doing rsps for profit, theres servers that make alot of money, and i want to get a piece of the pie.
by the way, this is not delta.
and also, moparscape is getting shut down.


That's illegal

the client is illegal, but no one needs to work on that.
13  Discussions / Business and Project Management Discussions / Re: runescape private servers - looking for developer on: 2012-03-15 04:51:09
Dude, PLEASE do not bring Runescape to these forums..
go to moparscape.org.
*Cough* Delta.
this is a java forum, private servers are written in java, I see no reason why I cant post this here.
I'm doing rsps for profit, theres servers that make alot of money, and i want to get a piece of the pie.
by the way, this is not delta.
and also, moparscape is getting shut down.
14  Discussions / Business and Project Management Discussions / runescape private servers - looking for developer on: 2012-03-15 02:39:58
hello, im looking for a developer to help work on a 317 based runescape private server, also looking for unique ideas.

some pictures:



[LINKS IF CANT SEE PICS]
http://screensnapr.com/v/uxuLLj.png
http://screensnapr.com/v/Q98qP0.png
15  Discussions / General Discussions / Re: best way to learn java on: 2012-01-08 21:13:23
I learnt by following youtube videos and tutorials I found online, I have never been a big fan of learning from books but the only one I do recommend is 'Sams, Teach yourself JAVA in 24 hours, 6th edition' its £24 from waterstones,

the two youtube channels I recommend looking at for great java video tutorals are 'My Bring Back' and 'TheNewBoston'.
thats the book i actually have haha XD
16  Discussions / General Discussions / Re: best way to learn java on: 2012-01-08 05:23:13
I can chime in with my take on tutorials or learning different programming paradigms, but I guess the important question is: where do you get stuck?  Everyone gets stuck sometimes, and it's usually just from trying to do something too complex all in one bite, and not really understanding all the pieces of the problem before trying to write a solution.  If you could give a more specific example of one or two places you've gotten stuck, the rest of us might have some advice or stories that can help break the jam.

 
basically, everything, i want to write a game, 2d or 3d it doesnt matter, but i have no idea where to start... how to load maps, how to load images, etc...
17  Discussions / General Discussions / Re: best way to learn java on: 2012-01-08 05:10:16
Honestly, if I were to put 2 years into something and saw barely any result, I'd pick another hobby.

Maybe you simply need a teacher, but I'd advice you to look elsewhere for things you both like and easily grasp.

2 years is a little exaggeration, i am really into it though.
but I'd advice you to look elsewhere for things you both like and easily grasp.

I agree, you have to enjoy coding a lot. Try to make a simple console game. When you get stuck, look up what's wrong with your code. Don't just copy paste someone else's code. You should make the program COMPLETELY from scratch. If you don't find it fun at all then you will never be able to program. It's good to have someone to ask simple questions but if you are getting them to do the work for you then you won't learn. If you don't get a sense of satisfaction when you get something working this is a good indicator that programming is not for you.

i want to program, i did exxagerate a bit in my post, i have created things very very simple, but i eventually get stuck at a point and dont know where to look for answer, programming is definately for me, i have the patience, i lvoe to do it, but i need a way to expand my knowledge of it, because these ways arnt working.

ah yes - I know what point you are talking in learning programming you are talking about, I don't speak from experience but I've seen it it many people
its the point where - you can theoretically program
but when you try to do something practical, you fail at problem-solving using what java offers / what you can do in programming
this is kinda like when someone learns riding a bike, and even though he knows how to do it, after a little while, he just keeps falling

I remember a friend of mine, who today is earning his money with programming - he was at this point
and he wanted to do a games and stuff, but could solve simple problem, like I remember he asked me "I want to ship to able to dock here, and I want a popup message" and I asked "well whats the problem exactly?" and he said "well I don't even know how to start."

You dont know what you can do yet and how it's going to able to shape what you want to do
And I'm pretty sure that this is simply a problem of experience.

I programmed like A LOT of incomplete games and programs when I started. So I'm not sure what to recommend. As I recall Stanford is using the ACM libraries so that the students can easily program some graphical things and get a feel of it - without caring about details so much. Can be done with AWT too I'm sure.
I am still a student right now, and from many many many examples - I can only say: Don't program console stuff.
It's less intuitive, its tedious and the results aren't fun. Fun is the most important aspect of learning. And when doing graphics you really get that sense of accomplishment.
This is kinda why Stanford uses the ACMs, because creating an AWT Frame or whatever - there is already "a lot" of code you just gotta ignore as a beginner, which ACM really simplifies - but in a nutshell, that is what I recommend, because then you just try playing with settings/parameters and adding and removing and eventually you get it.

this is the PERFECT example of what i mean, what do you suggest?
18  Discussions / General Discussions / Re: best way to learn java on: 2012-01-08 04:51:43
Honestly, if I were to put 2 years into something and saw barely any result, I'd pick another hobby.

Maybe you simply need a teacher, but I'd advice you to look elsewhere for things you both like and easily grasp.

2 years is a little exaggeration, i am really into it though.
but I'd advice you to look elsewhere for things you both like and easily grasp.

I agree, you have to enjoy coding a lot. Try to make a simple console game. When you get stuck, look up what's wrong with your code. Don't just copy paste someone else's code. You should make the program COMPLETELY from scratch. If you don't find it fun at all then you will never be able to program. It's good to have someone to ask simple questions but if you are getting them to do the work for you then you won't learn. If you don't get a sense of satisfaction when you get something working this is a good indicator that programming is not for you.

i want to program, i did exxagerate a bit in my post, i have created things very very simple, but i eventually get stuck at a point and dont know where to look for answer, programming is definately for me, i have the patience, i lvoe to do it, but i need a way to expand my knowledge of it, because these ways arnt working.
19  Discussions / General Discussions / best way to learn java on: 2012-01-08 04:37:29
hello, i have been trying to learn java for over 2 years now, but still cant even write a line of code, i have tried different methods, official java tuts, tuts on multiple other sites, books, videos, looking through source code, etc. but STILL i cant seem to just quite get a grasp on the language.... its quite frustrating... so im asking, how have you guys learned, any suggestions?
20  Game Development / Game Play & Game Design / minecraft-like games? on: 2012-01-07 17:26:38
looking for a minecraft type game to mess around with, are there any source release of such?
21  Game Development / Game Play & Game Design / changing the format of an item list.. on: 2012-01-02 22:13:02
hi, im implenting a different loading system for items in my project, i want to convert my old file format to the new one, without manually going through over 8000 items...

i was thinking of writing some kind of convertor, to dump it into new format, but have no idea to do so.

heres the new format:


old format:
1  
item = 0   Dwarf_remains   The_body_of_a_Dwarf_savaged_by_Goblins.   1   1   1   0   0   0   0   0   0   0   0   0   0   0   0
22  Game Development / Game Mechanics / Re: best way of loading character(player) files? on: 2011-09-21 04:36:32
"Player character files" doesn't mean anything, I'm afraid.

Do you mean configuration files?

There are many options for that. Java properties, XML, JSON, YAML, etc.
its the file where the players character info is loaded, like there bank account, coins, skills, etc.
23  Game Development / Game Mechanics / best way of loading character(player) files? on: 2011-09-21 04:22:41
what is the best way to load player character files? xml? .txt?
24  Game Development / Newbie & Debugging Questions / Re: server wont run? on: 2011-09-18 18:10:58
How exactly do you run it? From within an IDE or from the command line?
eclipse ide
25  Game Development / Newbie & Debugging Questions / Re: server wont run? on: 2011-09-16 22:29:05
Do you have your files in a jar? if so you need a Manifest.mf file in the meta-inf fold. The manifast file have a line with Main-Class: lf.Server
its not built into a jar, im just running it from the source.
26  Game Development / Newbie & Debugging Questions / server wont run? on: 2011-09-16 21:13:23
i need a little help, me and a friend are writing a Runescape private server, the base is almost done but for some reason the server just wont run.


im getting a run error cant find main.

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  
package lf;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;
import lf.item.Item;
import lf.util.HostThrottle;

public class Server implements Runnable {

    public Server() {
    }
    public static final int cycleTime = 600;

    public static void main(String args[]) throws Throwable {
        if (args.length != 3) {
            System.out.println("Usage: [OnSource_password] [OnSource_port] [startup_wait]");
            return;
        }
        OnSource.init(args[0], args[1], args[2]);

        Thread t = new Thread() {

            @Override
            public void run() {

                Scanner in = new Scanner(System.in);
                while (true) {
                    try {
                        String[] args = in.nextLine().split(" ");
                        args[0] = args[0].toLowerCase();

                        if (args[0].startsWith("stop")) {
                            System.out.println("Stopping server...");
                            playerHandler.update(Integer.parseInt(args[1]));
                            Thread.sleep(Integer.parseInt(args[1]) * 1000);
                            Server.stopServer = true;
                            Server.join(250L);
                            System.out.println("Server stopped.");
                        }

                    } catch (Throwable t) {
                        t.printStackTrace();
                    }
                }
            }
        };
        t.setDaemon(true);
        t.start();

        try {
            Item.initDefs();

            clientHandler = new Server();
            (new Thread(clientHandler)).start();

            playerHandler = new PlayerHandler();

            while (!stopServer) {
                long start = System.nanoTime();
                try {
                    playerHandler.process();

                } finally {
                    long time = 600L - ((System.nanoTime() - start) / 1000000L);
                    if (time > 0L) {
                        Thread.sleep(time);
                    }
                }
            }

        } finally {
            playerHandler.destruct();
            clientHandler.destruct();
            down = true;
        }
    }
    public static boolean down;
    public static Server clientHandler;
    public static ServerSocket clientListener;
    public static boolean stopServer = false;
    public static boolean stopListener;
    public static final int GAME_PORT = 43593;
    public static PlayerHandler playerHandler;

    public static void join(long step) throws InterruptedException {
        while (!Server.down) {
            Thread.sleep(step);
        }
    }

    public void run() {
        HostThrottle ht = new HostThrottle(3);
        ServerSocket ss = null;
        try {
            try {
                ss = new ServerSocket(GAME_PORT);
                Misc.println("Game server listening on " + ss.getInetAddress().getHostAddress() + ":" + ss.getLocalPort());

                do {
                    Socket sock = ss.accept();
                    if (ht.register(sock)) {
                        sock.setTcpNoDelay(true);
                        sock.setTrafficClass(0x04 | 0x08);
                        playerHandler.newPlayer(sock);

                    } else {
                        sock.close();
                    }

                } while (!stopListener);

            } finally {
                if (ss != null) {
                    ss.close();
                }
            }

        } catch (IOException e) {
            if (!stopListener) {
                e.printStackTrace();
            } else {
                Misc.println("Game listener shut down");
            }
        }
    }

    public void destruct() {
        try {
            stopListener = true;
            if (clientListener != null) {
                clientListener.close();
            }

        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}
27  Game Development / Game Play & Game Design / java 2.5d game engine? (like doom) on: 2011-09-12 04:31:05
looking for a java 2.5d game engine, ive tried like all of them i could find on sourceforge... none seem to work like i want. anyone know of any?
28  Game Development / Newbie & Debugging Questions / Re: loading a TMX map file? on: 2011-09-08 15:06:17
Just parse the XML and then present the data in your game however you want?
im completely new to java, i know its a noob question lol Tongue

and to the poster above, thanks, i looked in the docs and found the stuff for tiled Cheesy
29  Game Development / Newbie & Debugging Questions / Re: loading a TMX map file? on: 2011-09-08 12:37:32
i havnt started working on it.

nothing to present so far.
i want to load the map just so i can see it outside of the map editor (which im using "Tiled") in the client.
program is called Tiled.
client.

thanks.
30  Java Game APIs & Engines / Engines, Libraries and Tools / using flash animations in a 2d java game? on: 2011-09-08 04:47:31
is there an api for loading flash animations in a java game? any help appreciated.
Pages: [1] 2
 

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 (12 views)
2014-08-28 18:26:30

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

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

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

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

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

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

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

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

BurntPizza (33 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!