Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (724)
Games in Android Showcase (216)
games submitted by our members
Games in WIP (791)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 ... 8 9 [10]
 91 
 on: 2017-04-24 09:24:02 
Started by Ecumene - Last post by SHC
Am making a tower defense game, and I decided to make the turrets fire to the nearest point in the path of enemies. Then I also wanted to do optimized code, that is, the nearest point will only be computed on the creation of the turret and not with every projectile created.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
if (nearestPathPoint == null)
{
    nearestPathPoint = path.get(0);

    for (Vector2 pt : path)
        if (pt.distanceSquared(this.position) < nearestPathPoint.distanceSquared(this.position))
            nearestPathPoint = pt;
}

// Now fire projectile towards nearestPathPoint after timer

But when creating the turrets, all turrets are firing towards same point. Then after an hour I realized, that I accidentally declared nearestPathPoint as static when it shouldn't be. Precious amount of time in LudumDare JAM.

 92 
 on: 2017-04-24 07:15:09 
Started by Half_NO_oB - Last post by Half_NO_oB
Hi guys

I'm still developing a platformer, but I don't get to draw a polygon on my screen. Im using a Group-Node as the root, that is used as a parent for the Scene-Object. Then canvas is then added. I'm not using a Layout/Stack-Pane/Grid-Pane...

I'm having a player object that is containing an Object of class HUD(displaying stats and stuff). I can draw Images without problems, but how can i draw a Rectangle/Polygon onto a canvas?

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  
@Override
   public void start(Stage primaryStage) throws Exception
   {
      primaryStage.setTitle("Platformer");

      Group root = new Group();
     
      Scene scene = new Scene(root, WIDTH, HEIGHT);
     
      Canvas canvas = new Canvas(WIDTH,HEIGHT);
      root.getChildren().add(canvas);

      GraphicsContext gc = canvas.getGraphicsContext2D();
     
      MapManager.getInstance().loadAllMaps("maps");
     
      tileMap = MapManager.getInstance().getCurrentTileMap();
     
      player = new Player(tileMap);
      player.setX(64);
      player.setY(64);
     
      scene.setOnKeyPressed(
            event -> {
               String code = event.getCode().toString();
               
               if(code == "W")
               {
                  player.setJumping(true);
                }
               if(code == "A")
               {
                  player.setLeft(true);
               }
               if(code == "D")
               {
                  player.setRight(true);
               }
            });
     
      scene.setOnKeyReleased(
            event -> {
               String code = event.getCode().toString();
               
               if(code == "A")
               {
                  player.setLeft(false);
               }
               if(code == "D")
               {
                  player.setRight(false);
               }
            });
     
      AnimationTimer at = new AnimationTimer()
      {
         @Override
         public void handle(long now)
         {
            update();
            render(gc);
         }
         
      };
      at.start();      
     
      primaryStage.setScene(scene);
      primaryStage.show();      
   }


Any ideas how to?

Greetz HalfNoob

 93 
 on: 2017-04-23 23:39:00 
Started by Ercules76 - Last post by Ercules76
Ok i try to explain.
I've a player sprite with animations, WALKING, IDLE, JUMPING ecc.
The sprites are only with characters without nothing in his hands, now i create a shooting function and i want that when my char fire an enemy in the hand must have a gun, gun is another sprite outside player's sprite. I want something overlap a kind of child of a player object.

 94 
 on: 2017-04-23 21:07:12 
Started by Ecumene - Last post by CoDi^R
Doing a small side project with Direct State Access (DSA) in "modern" GL 4.5. About an hour of my life I won't get back...  Roll Eyes

 95 
 on: 2017-04-23 20:54:42 
Started by GameNewbie - Last post by KaiHH
I don't know whether libGDX provides you with a way to specify arbitrary affine coordinate system transformations for your sprites.
If so, then your are looking for the following transformations:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
// We start with the world coordinate system as reference
// and we would like to position our rocket at its position
// in the world and rotate it around its own origin:
translate(rocketPosition)
rotate(rocketRotation)
// Now we can draw the rocket
// ...draw it...
// Next, being in the local frame of the rocket, we want
// to position the exhaust flame at the bottom of the rocket.
// Given that the size of the rocket in its own local coordinate
// system is 'rocketHeight', and the origin is at the center
// of the rocket, we do the following now:
translate(0, -rocketHeight/2)
// ...draw exhaust flame...

Generally, you want a kind of "parent/child" relationship for transformations, where the transformation of the exhaust flame is relative to the rocket. This can be done using a scene graph. I don't know whether libGDX provides such as scene graph for 2D.

 96 
 on: 2017-04-23 20:41:30 
Started by lifemakers - Last post by lifemakers
We've released version 2 of Battle of the Pucks!

- Two new levels (10 boards each), with many old boards updated or regrouped for a more logical gameplay progression. Total levels in this version: 7, total boards: 70!



- Start a new game from ANY unlocked level, not just level 1! A level-choice screen lists all locked and unlocked levels so you can track your progress.



- Added new, updated existing color schemes: brighter & more vivid colors!



- Android Immersive mode: Play full screen without the Android buttons taking space!

- Nicer animations and new visual effects!

- Fixed display on large-aspect-ratio devices such as Samsung Galaxy S8

- Fixed several bugs, including "black screen" after restart

Thanks to all our testers! Your detailed reviews and ideas have been invaluable.

What to expect in version 3: OBSTACLES! Barriers, borders, walls, pegs... insanely challenging and insanely addictive. Watch for announcements!

 97 
 on: 2017-04-23 19:03:18 
Started by GameNewbie - Last post by bmanmcfly
It might be helpful to draw it out...

It sounds like you want the image to line up with the bottom middle of the rocket, the trouble you will find has to do with lining up the origins when the x axis is rotated at 30 degrees, that bottom middle you'll need to work out the trig relationship between the two sprites... 

it almost might be easier to have them as a single sprite with engine on vs engine off...

 98 
 on: 2017-04-23 18:55:56 
Started by Ercules76 - Last post by bmanmcfly
I think your question needs further clarification before any meaningful advice can be given.

 99 
 on: 2017-04-23 18:15:42 
Started by Ercules76 - Last post by Ercules76
Hi all guys, i'm new with videogame and java videogame, i try to make a platform 2D and i don't know how can add a weapon to my player, i have a sprite for weapon and a sprite for player. Someone can help me?

 100 
 on: 2017-04-23 06:15:41 
Started by Archive - Last post by Roquen
RBG isn't a good space to measure color differences.  Web search: "perceptual color spaces"  You'll also get better results if you don't simply map each pixel directly to a palette entry.  There are various methods, search "error diffusion"

Pages: 1 ... 8 9 [10]
 
Archive (37 views)
2017-04-27 17:45:51

buddyBro (246 views)
2017-04-05 03:38:00

CopyableCougar4 (670 views)
2017-03-24 15:39:42

theagentd (668 views)
2017-03-24 15:32:08

Rule (717 views)
2017-03-19 12:43:22

Rule (691 views)
2017-03-19 12:42:17

Rule (693 views)
2017-03-19 12:36:21

theagentd (707 views)
2017-03-16 05:07:07

theagentd (639 views)
2017-03-15 22:37:06

theagentd (480 views)
2017-03-15 22:32:18
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!