Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (593)
Games in Android Showcase (168)
games submitted by our members
Games in WIP (647)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 ... 3 4 [5] 6 7 ... 10
 41 
 on: 2015-07-02 17:31:58 
Started by orangepascal - Last post by orangepascal
Big sales spike?

Cas Smiley

it was short after release, so it's part of the release spike Wink
but it does make for nice long-tail sales (pretty sure it helps having it on the editor-choice page)

 42 
 on: 2015-07-02 15:22:03 
Started by deepthought - Last post by theagentd
http://store.steampowered.com/sale/steam_machines
Nvidia Geforce GTX graphics cards? Intel Core CPUs? How awfully specific of them. Is that a 200$ GTX 960 or a 650$ GTX 980? Well, considering the price of the entire thing (450$) I'd guess they're intentionally vague since they'll definitely use the cheapest hardware they can get away with. That being said, they're still significantly more powerful than the "next gen" consoles.

Quote
The Alienware Steam Machine combines the awesome experience of console gaming with a massive library of over 1000 games, all in full 1080p HD on your TV. You’ll experience powerful and immersive gaming with the high performance NVIDIA® GeForce® GTX GPU 2GB GDDR5 graphics and Intel® Core processors.
The sad part is that it's 2015 and this is actually impressive for console players...

 43 
 on: 2015-07-02 14:11:52 
Started by deepthought - Last post by deepthought
I was just wondering if they were trying to subsidize or sell at a loss like consoles do.

 44 
 on: 2015-07-02 14:03:00 
Started by gmoralis - Last post by gmoralis
Raiden support (nec v30 cpu ) available at github




 45 
 on: 2015-07-02 12:22:14 
Started by tommohawkaction - Last post by tommohawkaction
Is this:

1  
float g = (float) (parent.g - Math.sqrt((currentX * currentX) + (currentY * currentY)));

Based on the tutorial you're following? It still doesn't look right to me. For one thing, it seems the 'g' cost would get smaller with each successive node. Also, the distance from the origin to the current position isn't really relevant here. And, I don't see the move cost (10 or 14) incorporated anywhere.

Anyway, maybe the code could use another look. The best thing to do would probably be to step through it in the debugger, but at the very least, you could print out the 'g' cost at each step, just to make sure you're getting sensible values (e.g. no negative numbers, etc.).


I have re wrote this code, and followed the tutorial extremely slow but nothing works?
I am following this tutorial

http://www.policyalmanac.org/games/aStarTutorial.htm

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 com.hawk.linear.engine.path;

import java.util.ArrayList;

import com.hawk.linear.engine.collisioin.CollisionTileEngine;
import com.hawk.linear.engine.map.TileMap;

public class APathfind {

   private ArrayList<Node> openList;
   private ArrayList<Node> closedList;
   private TileMap map;
   private Node finalResult;

   public APathfind(TileMap map) {
      openList = new ArrayList<Node>();
      closedList = new ArrayList<Node>();
      this.map = map;
   }

   public void calculatePath(int startTileX, int startTileY, int targetTileX, int targetTileY) {
      openList.clear();
      closedList.clear();

      int currentX = startTileX;
      int currentY = startTileY;

      Node startNode = new Node(currentX, currentY);
      Node parent = startNode;
      openList.add(startNode);

      while (currentX != targetTileX && currentY != targetTileY) {

         Node top = calculateNode(currentX, currentY + 1, targetTileX, targetTileY, parent, 10);
         Node bot = calculateNode(currentX, currentY - 1, targetTileX, targetTileY, parent, 10);
         Node left = calculateNode(currentX - 1, currentY, targetTileX, targetTileY, parent, 10);
         Node right = calculateNode(currentX + 1, currentY, targetTileX, targetTileY, parent, 10);

         Node topLeft = calculateNode(currentX - 1, currentY + 1, targetTileX, targetTileY, parent, 14);
         Node topRight = calculateNode(currentX + 1, currentY + 1, targetTileX, targetTileY, parent, 14);
         Node botLeft = calculateNode(currentX - 1, currentY - 1, targetTileX, targetTileY, parent, 14);
         Node botRight = calculateNode(currentX + 1, currentY - 1, targetTileX, targetTileY, parent, 14);

         if (!CollisionTileEngine.checkCollisionTile(top.currentX, top.currentY, map.getMapData())) {
            openList.add(top);
         }
         if (!CollisionTileEngine.checkCollisionTile(bot.currentX, bot.currentY, map.getMapData())) {
            openList.add(bot);
         }
         if (!CollisionTileEngine.checkCollisionTile(left.currentX, left.currentY, map.getMapData())) {
            openList.add(left);
         }
         if (!CollisionTileEngine.checkCollisionTile(right.currentX, right.currentY, map.getMapData())) {
            openList.add(right);
         }

         if (!CollisionTileEngine.checkCollisionTile(topLeft.currentX, topLeft.currentY, map.getMapData())) {
            openList.add(topLeft);
         }
         if (!CollisionTileEngine.checkCollisionTile(topRight.currentX, topRight.currentY, map.getMapData())) {
            openList.add(topRight);
         }
         if (!CollisionTileEngine.checkCollisionTile(botLeft.currentX, botLeft.currentY, map.getMapData())) {
            openList.add(botLeft);
         }
         if (!CollisionTileEngine.checkCollisionTile(botRight.currentX, botRight.currentY, map.getMapData())) {
            openList.add(botRight);
         }
         if (openList.contains(startNode)) {
            openList.remove(startNode);
            closedList.add(startNode);
         }

         // Checking smaller F cost
         float maxF = Float.MAX_VALUE;
         Node checkNode = null;
         for (Node n : openList) {
            if (n.f < maxF) {
               maxF = n.f;
               checkNode = n;
            }
         }
         // Set new parent
         openList.remove(checkNode);
         closedList.add(checkNode);

         parent = checkNode;
         currentX = checkNode.currentX;
         currentY = checkNode.currentY;

         checkOpenListNode(top, parent);
         checkOpenListNode(bot, parent);
         checkOpenListNode(left, parent);
         checkOpenListNode(right, parent);

         checkOpenListNode(topLeft, parent);
         checkOpenListNode(topRight, parent);
         checkOpenListNode(botLeft, parent);
         checkOpenListNode(botRight, parent);
      }
     
      for(Node node : openList){
         if(node.currentX == currentX && node.currentY == currentY){
            finalResult = node;
            return;
         }
      }
   }

   public Node getFinalResult() {
      return finalResult;
   }

   private void checkOpenListNode(Node node, Node parent) {
      for (Node n : openList) {
         if (n.currentX == node.currentX && n.currentY == node.currentY) {
            if (node.g < n.g) {
               n.g = node.g;
               n.f = node.f;
               n.parent = parent;
            }
         }
      }
   }

   private Node calculateNode(int currentX, int currentY, int targetTileX, int targetTileY, Node parent, int moveCost) {
      // H (From current to target)
      float hx = Math.abs(targetTileX - currentX);
      float hy = Math.abs(targetTileY - currentY);
      float h = (hx + hy);

      // G (Movement Cost)
      float g = (float) Math.sqrt((currentX * currentX) + (currentY * currentY));

      // F (G + H)
      float f = g + h;
      Node node = new Node(h,g,f, parent, currentX, currentY);
      return node;
   }
}

 46 
 on: 2015-07-02 10:53:36 
Started by tommohawkaction - Last post by Jesse
Is this:

1  
float g = (float) (parent.g - Math.sqrt((currentX * currentX) + (currentY * currentY)));

Based on the tutorial you're following? It still doesn't look right to me. For one thing, it seems the 'g' cost would get smaller with each successive node. Also, the distance from the origin to the current position isn't really relevant here. And, I don't see the move cost (10 or 14) incorporated anywhere.

Anyway, maybe the code could use another look. The best thing to do would probably be to step through it in the debugger, but at the very least, you could print out the 'g' cost at each step, just to make sure you're getting sensible values (e.g. no negative numbers, etc.).

 47 
 on: 2015-07-02 10:33:30 
Started by tommohawkaction - Last post by tommohawkaction
Thanks for pointing it out

1  
2  
3  
4  
5  
6  
7  
8  
      // Top
      // H (From current to target)
      float hx = Math.abs(targetTileX - currentX);
      float hy = Math.abs(targetTileY - currentY);
      float h = (hx + hy) * moveCost;

      // G (Movement Cost)
      float g = (float) (parent.g - Math.sqrt((currentX * currentX) + (currentY * currentY)));



The result was the same though


 48 
 on: 2015-07-02 10:24:01 
Started by orangepascal - Last post by princec
Big sales spike?

Cas Smiley

 49 
 on: 2015-07-02 10:07:12 
Started by TGStudios - Last post by ags1
I wouldn't stress about it, you have to start somewhere. All source code is ultimately copy-pasted from StackOverflow. This includes the code snippets on StackOverflow itself. Smiley

 50 
 on: 2015-07-02 09:48:04 
Started by orangepascal - Last post by orangepascal
I spotted Gunslugs 2 listed under Editors Choice on Google Play, well done and well deserved!

thanks! was pretty cool to get that indeed Smiley

Pages: 1 ... 3 4 [5] 6 7 ... 10
 
deepthought (40 views)
2015-06-30 15:39:44

deepthought (43 views)
2015-06-30 15:39:09

deepthought (54 views)
2015-06-30 15:36:52

Za\'Anzabar (24 views)
2015-06-29 05:44:54

TritonDreyja (41 views)
2015-06-24 17:10:40

CopyableCougar4 (37 views)
2015-06-23 00:34:45

BurntPizza (43 views)
2015-06-21 20:36:46

cookiecompiler (85 views)
2015-06-11 15:42:53

cookiecompiler (48 views)
2015-06-11 15:41:14

NegativeZero (76 views)
2015-06-11 09:49:18
How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14
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!