Show Posts
|
|
Pages: [1] 2
|
|
4
|
Game Development / Game Mechanics / Re: Level creator
|
on: 2012-05-24 23:37:54
|
|
I'm making a sidescrolling platformer, which is what I gather you're making, a tile map, should be fine for doing a sidescroller, it's what Im using, plus its easy to do everything can be stored in a 2 dimensional array.
|
|
|
|
|
5
|
Game Development / Game Play & Game Design / Re: [Help]Platformer Pathfinding
|
on: 2012-05-07 12:46:42
|
The same way you simulate the movements for the player? We're rapidly getting into "write my game for me" territory I think. What have you tried? What didn't work?
For jumping, I originally had the enemy follow a bezier curve between the two waypoints. Later I changed it to just simulate a proper jump - finding the launch speed and angle is the only tricky bit, but that's just a bit of trig really. What I meant was, I'm not simulating the movement for my player, I'm just moving them, by simulating I assume that means playing through possible movements without actually moving the NPC and seeing which one is best, I'm not asking anyone to write my game for me, as then I wouldn't learn anything and I couldn't feel pride in the final product, I'm sorry if it came across that way, but this is my first real game attempt and I'm new to this...
|
|
|
|
|
6
|
Game Development / Game Play & Game Design / Re: [Help]Platformer Pathfinding
|
on: 2012-05-07 12:12:58
|
|
How would I go about simulating the movements? It would mean anticipating collision, the NPCs knowing when/where to jump... Also, in the future I want to have some team-mate NPCs who follow and fight with the player, would a similar system work for this?
|
|
|
|
|
7
|
Game Development / Game Play & Game Design / Re: [Help]Platformer Pathfinding
|
on: 2012-05-07 00:14:39
|
A* can be used on any graph to find a route from one node to another, not just top down maps. You just need to find a way of representing your platform level as a suitable graph that can be traversed. Previously I've done that by generating waypoints at regular intervals along the surface of the platforms, then generating links between adjacent waypoints, like this:  Here, the greed diamonds are waypoints and the white lines the available routes between nearby waypoints. You'll need to generate links not just from waypoints on the same platform, but between waypoints on different platforms that you can jump between. How would I make this look natural, so the entity doesn't just fly there following straight lines, it jumps, and the jump curves like a normal jump...?
|
|
|
|
|
9
|
Game Development / Game Play & Game Design / [Help]Platformer Pathfinding
|
on: 2012-05-06 17:48:34
|
 I've been thinking about how to do path finding for my 2D platformer, I want the enemies to be able to find their way towards the player and jump on to higher platforms to reach them... I looked into the A* algorithm but it seems to be more suited to top down games and I was wondering if anyone had any good ideas regarding platformer pathfinding?
|
|
|
|
|
10
|
Game Development / Game Mechanics / Re: [Help]2D tile map lighting
|
on: 2012-04-26 17:29:06
|
|
I'm now trying to figure out how to smooth the shadows, so they're not so sharp... I thought about having it check all the tiles that the torch has lit and checking if they have any unlit tiles next to them, if they do, changing the unlit tile's light value to something slightly higher... but that'd be messy...
|
|
|
|
|
12
|
Game Development / Game Mechanics / Re: [Help]2D tile map lighting
|
on: 2012-04-25 23:38:10
|
Ok, I'll post up the code now, it's not working for the top left hand side, when the line gets past the tile above the one that I'm checking from... 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
|
package kingdom.blue;
import java.awt.Point; import java.io.IOException; import java.net.URL; import javax.imageio.ImageIO;
public class TileTorch extends Tile {
public TileTorch(int x, int y, map m){ lightLevel = 5; floorBlock = false; lightSurroundings(x,y,m); } public void lightSurroundings(int x, int y,map m){ int firstx = x-4; int firsty = y-4; for(int x1 = firstx;x1 < x+4;x1++){ for(int y1 = firsty;y1 < y+4;y1++){ if(tileVisible(x,x1,y,y1,m)){ if(x1 > -1 && x1 < map.WIDTH){ if(y1 > -1 && y1 < map.HEIGHT){ if(m.Map[x1][y1] != null){ m.Map[x1][y1].lightLevel = 5; System.out.println("lighting tile!"); } } } } } }
} public static boolean tileVisible(int x1, int x2, int y1, int y2, map m){ int xinc1; int xinc2; int yinc1; int yinc2; int abs; int den; int num; int numadd; int numTiles; int deltax = (int)(x2 - x1); int deltay = (int)(y2 - y1); int x = x1; int y = y1;
if (x2 >= x1) { xinc1 = 1; xinc2 = 1; } else { xinc1 = -1; xinc2 = -1; }
if (y2 >= y1) { yinc1 = 1; yinc2 = 1; } else { yinc1 = -1; yinc2 = -1; }
if (deltax >= deltay) { xinc1 = 0; yinc2 = 0; den = deltax; num = deltax / 2; numadd = deltay; numTiles = deltax; } else { xinc2 = 0; yinc1 = 0; den = deltay; num = deltay / 2; numadd = deltax; numTiles = deltay; }
for (int currentTile = 0; currentTile <= numTiles; currentTile++) { if(x > -1 && x <= map.WIDTH){ if(y > -1 && y <= map.HEIGHT){ if(m.Map[x][y] != null){ if(m.Map[x][y].lightBlock){ return false; } } } } num += numadd; if (num >= den) { num -= den; x += xinc1; y += yinc1; } x += xinc2; y += yinc2; } return true; }
}
|
Now I really am off to bed, I'll check back in the morning...
|
|
|
|
|
13
|
Game Development / Game Mechanics / Re: [Help]2D tile map lighting
|
on: 2012-04-25 23:29:21
|
Oh, looks like some angles/lines may not be working... oops, will just check that out... EDIT: Yeah it looks like when the line goes upwards and to the left it's not working... need to check why that is... I'll post up my code and possibly some screenshots tomorrow, so you can see what's happening, for now Im off to bed, as I am tired... but it's looking better than yesterday 
|
|
|
|
|
14
|
Game Development / Game Mechanics / Re: [Help]2D tile map lighting
|
on: 2012-04-25 23:26:56
|
|
Nah, it seems to be working fine now, thanks, I'll fiddle around with it, to get it looking exactly how I want it, but the hard work I feel is pretty much done for now, I shall clean up my code and post it up, in case anyone else wants a peek at it... Thanks for all the help! Everyone's been really helpful. I'll probably make a thread about my Game at some point so I can post more about it...
|
|
|
|
|
15
|
Game Development / Game Mechanics / Re: [Help]2D tile map lighting
|
on: 2012-04-25 23:19:06
|
Nothing shows up... I was using 2 for loops to run through the x/y positions I wanted to check for lighting... EDIT: Oh, It was due to a stupid error I made... no worries, seems to be working great  - Just need to clean it all up now, bit messy currently
|
|
|
|
|
19
|
Game Development / Game Mechanics / Re: 2D tiled map
|
on: 2012-04-25 22:15:01
|
|
Well without seeing your code I wouldn't know, is there anywhere in your game which only gets called once? where you could just call Map.render or whatever?
|
|
|
|
|
24
|
Game Development / Game Mechanics / Re: [Help]2D tile map lighting
|
on: 2012-04-25 20:42:12
|
First attempt didn't work - 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| public static boolean tileVisible(int x1, int x2, int y1, int y2, map m){ int deltax = x2 - x1; int deltay = y2 - y1; int y = y1; int ynum = deltax/2; for(int x = x1; x <= x2; x++){ if(m.Map[(int)(x-m.mapPosX)/m.TILE_SIZE_X][(y-m.mapPosY)/m.TILE_SIZE_Y].lightBlock){ return false; } ynum+= deltay; if(ynum >= deltax){ ynum -= deltax; y++; } } return true; } |
|
|
|
|
|
25
|
Game Development / Game Mechanics / Re: [Help]2D tile map lighting
|
on: 2012-04-24 21:42:01
|
That sounds simple, but it looks a bit more of a pain in the arse in practice...  Anyway, thanks for all the help, after I've changed my map system from an array of buffered images... I'll have a go at it, then post my results
|
|
|
|
|
27
|
Game Development / Game Mechanics / Re: [Help]2D tile map lighting
|
on: 2012-04-24 19:26:11
|
|
Fair enough, would the bit earlier about " if the gradient is greater than 1, do 1/gradient and step by y++ rather than x++." - would that work? or are there better ways to do it?
EDIT: Also, why is it that your code doesn't work above gradients of 1?
|
|
|
|
|
29
|
Game Development / Game Mechanics / Re: [Help]2D tile map lighting
|
on: 2012-04-23 23:29:32
|
Wow, thats really helpful thanks!, with the everything posted here I should be able to take a good swing at getting this working. But I'm off to bed as I'm tired... I'll make sure to post up progress later this week. 
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|