Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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  Discussions / General Discussions / Re: Where are you from? on: 2012-12-12 18:05:22
Hi, i'm 30 and i leave in France in Lyon city.

2  Game Development / Newbie & Debugging Questions / Re: Shooting a grenade on: 2012-10-24 16:13:38
Hello, I understand the principle.

Bravo, nice explanation.
The result is not yet perfect.
But it now looks like something.
As you pointed out, the grenade flies.
I finish studying the issue.

Thank you for your help.
I hope it could help other people
3  Game Development / Newbie & Debugging Questions / Re: Shooting a grenade on: 2012-10-24 11:50:10
Hi,

SHC your solution is simple,
but how i tried it.
The result is too straight.

The agent D, i like your solution, but i do not understand all of it.
I can not define the velocity and le gravity and the temp.

I'll stop to annoy you with my grenade throwing.
I'll continu and when i 'll have the solution, i'll post it here =)

To be continue...


If someone want to shoot a target whith a define duration, i do that :


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  
in constructor(Point _player, Point _target)
{
// player position
px = _player.getX();
py = _player.getY();

// grenade position
x = px;
y = py;

// target position
tx = _target.getX();
ty = _target.getY();

// Delta (distance between target and player)
dx =  (tx - px);
dy =  (ty - py);

// duration of the grenade move in ms
duration = 2000;
// step is the number of cycle (update)
step = (duration / Configuration.FRAMES_PER_SECOND);


// x and y velocities
vx = dx / step;
vy = dy / step;
}


in update()
{
x += vx;
y += vy;
}


that's all I can do for now =)
4  Game Development / Newbie & Debugging Questions / Re: Shooting a grenade on: 2012-10-24 04:47:18
Thanks a lot,
i'll try to finish it today (after work)
thanks you for yours answers =)
It was great help for me.
I'll say you when it'll be good.
5  Game Development / Newbie & Debugging Questions / Re: Shooting a grenade on: 2012-10-23 19:29:37
Ok guys =) First i wish to thank you really much.
Thanks for your answers.
Great forum, Great people !
Ok, so, i saw yours answers, but It’s not yet absolutely good for me.
I note I’m in the good to topic : Newbie and debugging ^^

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
My constructor : 
//The Points are the nodes references, cases where are player and target
public ShotPlayer(Game _game, Point _player, Point _target)
{
   // px py tx and ty are the positions in pixel on the frame
  // player position in pixel (the center of the case)
  px = (_player.getX() * Configuration.CASE_WIDTH) + (Configuration.CASE_WIDTH / 2);
   py = (_player.getY() * Configuration.CASE_HEIGHT) + (Configuration.CASE_HEIGHT / 2);
   // target position in pixel (the center of the case)
  tx = (_target.getX() * Configuration.CASE_WIDTH) + (Configuration.CASE_WIDTH / 2);
   ty = (_target.getY()* Configuration.CASE_HEIGHT) + (Configuration.CASE_HEIGHT / 2);
   // Delta (distance between target and player
  dx = tx- px;
   dy = ty - py;
   // Position of the grenade
  x = px;
   y = py;
}



1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
public void update() 
{
if (x > Configuration.WINDOW_WIDTH || y > Configuration.WINDOW_HEIGHT || y < 0 || x < 0 )
   game.removeShotsPlayerEntity(this);
   else
   {
// It is here where i must update the position of the grenade.
// I delete my linear function (the straight shot)
// But I didn’t know how to implement yours code… Sorry…
// Do you think the structure is good ?
// Do you think I’ll clear my pb… I wish
}
}


If you could still help me...


6  Game Development / Newbie & Debugging Questions / Shooting a grenade on: 2012-10-23 09:20:55
Hi everybody,

I'm working on a tiled based game,
In this game there are a player and a bot.

Actually the player can shot the target with a straight shot

The shots properties looks like something like that:

1  
2  
3  
4  
dx = target.x - player.x ;
dy = target.y - player.y ;
x = player.x + velocity * dx;
y = player.y + velocity * dy;


But now, i wish the player shot a grenade on the target.

Something like that :


My problem is that i don't know how to make a parabola between two points when the Y are differents.

If someone have an idea, i 'll be happy.
Thank.
7  Game Development / Newbie & Debugging Questions / Grid graphe course on: 2012-02-17 10:32:38
Hello hello,

Today I encounter some difficulties on using JGraphT.
I try to create a grid map (a matrix of squares)

And in the future, I will seek to make the shortest path, the structure of my map must be a graph.
After many trials, I opted for that lib quoted above.

Regarding the creation of the graph, it's easy and clear.
By cons I have missed something regarding the course of it.

Indeed for each node in the graph, I want to make some actions.
drawing for exemple.

I'm reading the Javadoc for 2h and search on Google and other website. I can not find a solution (which I think is not very complicated. (For each node ... to do...)

That's why I seek some help =)

little 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  
public class Model
{
   private JFrame jFrame;
   private Carte carte;
   
   public Model(JFrame _jFrame)
   {
      jFrame = _jFrame;
      initialize();
   }
   
   public void initialize()
   {
      carte = new Carte(this);
   }
   
   public void update()
   {
      carte.update();
   }
   
   public void draw(Graphics g)
   {
      carte.draw(g);
   }
}

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  
public class Carte
{
   private Model model;
   private UndirectedGraph<Case, DefaultEdge> graph;
   
   public Carte(Model _model)
   {
      model = _model;
      initialize();
   }

   public void initialize()
   {
      graph = createCasesGraph();
   }
   
   public void update()
   {

   }
   
   public void draw(Graphics g)
   {
      System.out.println(graph.toString());
      //**********************************
     // foreach node
     //   case.draw(g);
     //**********************************      
  }
   
   private static UndirectedGraph<Case, DefaultEdge> createCasesGraph()
   {
      UndirectedGraph<Case, DefaultEdge> g =
         new SimpleGraph<Case, DefaultEdge>(DefaultEdge.class);
     
      // Vertex
     Case v1 = new Case(0,0);
      Case v2 = new Case(0,1);
      Case v3 = new Case(1,0);
      Case v4 = new Case(1,1);

      g.addVertex(v1);
      g.addVertex(v2);
      g.addVertex(v3);
      g.addVertex(v4);

      // Edges
     g.addEdge(v1, v2);
      g.addEdge(v1, v3);
     
      g.addEdge(v2, v1);
      g.addEdge(v2, v4);
     
      g.addEdge(v3, v1);
      g.addEdge(v3, v4);
     
      g.addEdge(v4, v2);
      g.addEdge(v4, v3);
   
      return g;
   }
}

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  
public class Case 
{
   private int col;
   private int row;
   private int height;
   private int width;

   public Case()
   {
      this(0,0);
   }

   public Case(int _col, int _row)
   {
      col = _col;
      row = _row;
      initialize();
   }

   public void initialize()
   {
      height = 50;
      width = 50;
   }

   public void update()
   {

   }

   public void draw(Graphics g)
   {
      g.setColor(Color.black);
      g.fillRect(col * width, row * width, width, height);
      g.setColor(Color.white);
      g.drawRect(col * width, row * width, width, height);

      Graphics2D g2 = (Graphics2D) g;
      FontRenderContext frc = g2.getFontRenderContext();
      int fontSize = 11;
      Font f = new Font("Comic Sans MS",Font.BOLD, fontSize);

      String sScore = new String(col + "-" + row);
      TextLayout tScore = new TextLayout(sScore, f, frc);
      tScore.draw(g2,col * width, row * height + fontSize);
   }
}
8  Game Development / Newbie & Debugging Questions / Re: to jump on: 2011-10-28 18:54:26
Oki i'll try it.
But i think the result won't be a real beautifull parabola.
I'll try it and i'll say you if the result is good.

Thx  for answers.
9  Game Development / Newbie & Debugging Questions / Re: to jump on: 2011-10-28 14:45:17
Re hello.

My caracter (on the picture, the blue square) has coordinates

x and y.

When it is moving to right, x is increasing and to left it's decreasing.

Right.
Now, when there are an event (here for example : when the caracter is colliding a box) the caracter jumps.
The caracter jumps during 2 seconds on 300 pixel.

It is good for the x move.
But i can't get the y.

The problem is to find the y from the x.

(i wish to be clear ?)

The initials coodinates can be everything, it is not important.

(ex (200;500))



On this exemple we can see 3 phases.

  • Before jump
  • During the jump
  • After the jump

Before the jump Y don't change and x has a fix velocity.
During the jump y (i will find it one day  Smiley) and x adjust its velocity for the jump lenght (2 seconds)
After jump, x and y return to their initials states


Thx for the reply Zendar =)
10  Game Development / Newbie & Debugging Questions / to jump on: 2011-10-28 11:37:37
[size=12pt]Hello everybody.[/size]

I have a little conception problem, and i would like your opinion please.

[size=12pt]What i wish :[/size]

  • A caracter can jump
  • The width of jump is variale ( in pixel )
  • The length of jump is variable too ( in ms )

For exemple the caracter can make a jump on 300 pixels in 1 seconde or another on 600 in 3 secondes.
it must fallow a parabole

Actualy i have succeeded to get the X position.
But it's difficult to get the Y position.

[size=12pt]The code :[/size]

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  
        /**
    * Attributes
    */

        // is the caracter jumping ?
  private boolean isJumping = false;
   // is the jump begun ?
  private boolean isJumpingStarted = false;
   
   
   // Jump length (ex : 2 seconde)
  private int jumpPeriod = 2000;
   // Jump length index
  private long jumpIndex;
   
   // Frame / Second
  private final static int FPS = 1000/60;
   // Number of cycle during a jump
  private int jumpCycle = jumpPeriod / FPS;
   
   // Jump width
  private int jumpWidth = 300;
   // Step width / cycle
  private float pas = ((float)jumpWidth / (float)jumpCycle);

        /**
    *  Main loop
    */

   public void update()
   {
                // One external event put this boolean to true (mouse clic ou an another event for example)
     if(isJumping)
         jumping(System.currentTimeMillis());
   }

        /**
    * Jump function
    * @param gameTime
    */

   public void jumping(long gameTime)
   {
      // The jump was not yet initialised
     if(!isJumpingStarted)
      {
         jumpIndex = System.currentTimeMillis() + jumpPeriod;  
         isJumpingStarted = true;
      }
     
      // The jump is already initialised
     else
      {
         // Jump is finished
        // RAZ
        if(jumpIndex - gameTime <= 0)
         {
            isJumpingStarted = false;
            isJumping = false;
            velocity = BASIC_VELOCITY;
         }
         
         // Jump not finished
        // we change the velocity as a function of the length of the jump.
        else
         {
            velocity = pas;
         }
      }
   }


Do you think it right ?
Have you an advice for the y coordinate ?


[size=12pt]Thank for reading[/size]
and i wish my english is readable.


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.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (43 views)
2014-09-23 14:38:19

radar3301 (25 views)
2014-09-21 23:33:17

BurntPizza (62 views)
2014-09-21 02:42:18

BurntPizza (32 views)
2014-09-21 01:30:30

moogie (37 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
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!