Show Posts
|
|
Pages: [1] 2 3 ... 9
|
|
1
|
Game Development / Articles & tutorials / Re: Gravity
|
on: 2013-01-02 15:30:25
|
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
| private float x, y; private float vx, vy; private float elapsedTime = -1; private final float g = -10; private final float jumpingPower = 6;
private final int FPS = 60; private final float DELTA = 1f/FPS;
public void update() { if() { vy = jumpingPower; elapsedTime = 0; } if (elapsedTime != -1) { vy = elapsedTime * DELTA * jumpingPower + g / 2 * elapsedTime * elapsedTime * DELTA * DELTA; y += vy; elapsedTime++; } for(Blocks b : randomBlocks) { if(this.intersects(b)) { if (vy >= 0) { elapsedTime = -2f * jumpingPower / g; } else { vy = 0; elapsedTime = -1; } } } } |
That's my approach, from memory. Might have mistakes?
|
|
|
|
|
4
|
Java Game APIs & Engines / OpenGL Development / Re: Newbie Polygon Texturing Question
|
on: 2012-12-28 05:22:52
|
So I have to reuse vertices, it can just be one fluid motion, going from vertex to vertex. i.e. in my original drawing, I have to texture the triangles:
1, 2, 4 1, 3, 4 3, 4, 6 3, 5, 6 5, 6, 8 5, 7, 8 7, 8, 10 7, 9, 10
(I'm calling glVertex2f 24 times. When there are only 10 vertices)
You could use GL_TRIANGLE_STRIP which lets you reuse 2 vertices each time resulting in 10 glVertex2f() calls Interesting. Sounds like what I was looking for @davedes that's what the code I posted does, I just wasn't sure if I was taking the long way about doing it
|
|
|
|
|
5
|
Java Game APIs & Engines / OpenGL Development / Re: Newbie Polygon Texturing Question
|
on: 2012-12-28 05:19:35
|
|
So I have to reuse vertices, it can't just be one fluid motion, going from vertex to vertex. i.e. in my original drawing, I have to texture the triangles:
1, 2, 4 1, 3, 4 3, 4, 6 3, 5, 6 5, 6, 8 5, 7, 8 7, 8, 10 7, 9, 10
(I'm calling glVertex2f 24 times. When there are only 10 vertices)
|
|
|
|
|
6
|
Java Game APIs & Engines / OpenGL Development / Re: Newbie Polygon Texturing Question
|
on: 2012-12-28 05:02:26
|
It's OpenGL and the texture should be zig zagging. I have the effect working, it's just not very efficient: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| float difY = tile.top() - tile.bottom(); int offZ = off % 360; float o_ = 0; for (int z = offZ; z <= 360 + offZ; ) { float x_ = (float) (Math.sin(z * DEG_2_RAD) * 2 * PIXEL_X);
gl.glTexCoord2f(tile.left(), tile.bottom() + difY * (z - offZ) / 360); gl.glVertex2f(l + o_, b + h_interval * (z - offZ) / 360); gl.glTexCoord2f(tile.right(), tile.bottom() + difY * (z - offZ) / 360); gl.glVertex2f(r + o_, b + h_interval * (z - offZ) / 360); z += 30; o_ = x_;
gl.glTexCoord2f(tile.right(), tile.bottom() + difY * (z - offZ) / 360); gl.glVertex2f(r + x_, b + h_interval * (z - offZ) / 360); gl.glTexCoord2f(tile.left(), tile.bottom() + difY * (z - offZ) / 360); gl.glVertex2f(l + x_, b + h_interval * (z - offZ) / 360); } |
(h_interval is the height of a tile, l is the left x coordinate of a tile, r is the right x coordinate of a tile, b is the bottom y coordinate of a tile, offZ is just a number i'm incrementing after each render, to make the effect move) I'm trying to get a 'mirage' effect (tiles waving back and forth using sine. also i'm sure there's a way better way of doing this, if you know of it point it out) edit: how do I get the smallest number of triangles (not reuse vertices) is my question I guess, in response to your edit
|
|
|
|
|
7
|
Java Game APIs & Engines / OpenGL Development / Newbie Polygon Texturing Question
|
on: 2012-12-28 04:44:16
|
When texturing a polygon, what order do I have to follow exactly? Say I have this polygon  And I have a rectangular texture (of the same height, so the only thing changing is the x component) How do I achieve this? I have vertices 1-10, what order do I use them to texture the polygon? At the moment I'm breaking it up into quads and texturing those quads (using only a part of the texture) using these groups of vertices in this order: 1, 2, 4, 3 3, 4, 6, 5 5, 6, 8, 7 etc
|
|
|
|
|
9
|
Discussions / General Discussions / Re: Revenge of the Patent Trolls!
|
on: 2012-12-21 04:33:29
|
If you cannot patent anything mathematical, then all patents in all fields are disputable.  Computational or algebraic is a different story. [quibble]Shouldn't physics and chemistry be swapped?[/quibble] And this is gonna get thrown out (for now) because they called it "Mindcraft" lol
|
|
|
|
|
15
|
Game Development / Performance Tuning / Trapezoid!
|
on: 2012-11-20 00:48:11
|
I was wondering if there are any fast algorithms out there for taking an image and morphing it into the shape of a trapezoid (trapezium). I found this method: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| private final float A = W * 0.08f; private final float B = W * (1f - 0.08f);
private final void createTrapezium(BufferedImage src, BufferedImage out) { int[] pix = ((DataBufferInt) src.getRaster().getDataBuffer()).getData(); int[] pix2 = ((DataBufferInt) out.getRaster().getDataBuffer()).getData(); Arrays.fill(pix2, 0); for (int y = 0; y < HEIGHT; y++) { int yw = y * W; float y_to_h = y / (float) HEIGHT; float C_A_offset = A * (1 - y_to_h); float trapeziumLine = -C_A_offset + B + (W - B) * y_to_h; float k = trapeziumLine / W; for (int x = 0; x < W; x++) { int destX = (int) (C_A_offset + x * k); pix2[yw + destX] = pix[yw + x]; } } } |
But it's pretty CPU intensive (using this in real-time for a changing background image at 30 FPS)... Is there an alternative to using JAI?
|
|
|
|
|
17
|
Discussions / Miscellaneous Topics / Re: Who would you consider a programmer?
|
on: 2012-08-06 10:42:03
|
Little? You're too nice A programmer does not need to know how to make a compiler - a compiler developer needs to know that. A programmer needs to know how to USE a compiler. A programmer doesn't need to know how to make a networked game either. A 'hacker' does not need to know how to program at all... Most people would tell you that 'coder' and 'programmer' are the same thing and use them interchangeably.. I think he just threw 'scripter' in there for fun, first time I've heard that. Since if you're writing in a scripting language, you are still programming... He's a lot of off
|
|
|
|
|
20
|
Game Development / Artificial Intelligence / Re: A* with different sized units
|
on: 2012-07-08 12:31:53
|
Fy, rom what's been said, I think I understand the problem (Yay!), but I still haven't actually read the page yet (I'm just responding/talking through my little phone while I try to make a section of my house wheel chair accessible.)
Anyway, it seems that for an arbitary sized/shaped map (let's call it that, instead of infinite) that you have a few options.
1) Recompute the clearrance when more areas becoming visible.
2) Compute the clearance as soon as you can. However, this let's the path finder sort of "see beyond" the sight area of the creature when picking a route (the pathfinder gets the clearance values, which indicates open spaces, meaning it'll know where the creature can fit before it gets close enough to see.)
3) Attempt to disable the clearance path finding through unseen areas. Not sure how to accurately do this though.
4) Make a maximum limit on the clearance value of each tile (the smallest you can, and still fit your largest creature). Then, instead of recomputing each time you discover an area, you just mark a 'seen' flag, if it's seen, then you get it's actual clearnce values, if it's unseen you get it's unseen values (preferably either the maximum-- so that your path finder will assume that any sized creature can move through an unseen path-- or some arbitrary other value.) Still has the issue that the path finder can see a bit beyond the edges of the creature's vision (tiles on the edge of vision in certain directions with give information about what's further in that direction).
If you give us some idea about what you're trying to do: how you're genetrating your map, whwther vision matters (sort of assuming from what you said), etc. We might be able to give you an answer to better suit your needs.
Yes I just thought of #4 yesterday and all is going well. I'm just gonna finish making it work with rectangular units and all should be well. Thanks for pointing me in the right direction guys
|
|
|
|
|
21
|
Game Development / Artificial Intelligence / Re: A* with different sized units
|
on: 2012-07-07 15:14:47
|
problem is I have an 'infinite' map, is the only way to keep recalculating each time a new area has been discovered? I didn't quite understand how to set a clearance value for each tile for starters, (1, 2, 3, 4, 5, etc) so I thought looking at a java implementation would help
@ReBirth not sure what you meant
Treat a big tile as some small 1x1 tiles. You mean a 2x2 tile as 4 seperate 1x1 tiles? but how would that even work
|
|
|
|
|
25
|
Discussions / Business and Project Discussions / Re: runescape private servers - looking for developer
|
on: 2012-03-15 05:53:46
|
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
|
|
|
|
|
26
|
Discussions / Business and Project Discussions / Re: Can I have an Experience poll?
|
on: 2012-03-01 22:23:14
|
| Name | Time with Java | Games Made | Developed Ideas | Not so developed ideas | Learning | Education | Age | In collaboration | Need collaboration | | Mo (counterp) | 6 years | 1 that I've actually stuck with | Many | More than many | Nothing in particular at the moment | High school (no programming classes though?) | 17 | No one | No  |
|
|
|
|
|
28
|
Game Development / Newbie & Debugging Questions / Re: Java game - time
|
on: 2012-02-18 21:39:52
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| public boolean paused; public long pauseElapsed, pauseStarted; public void pause(boolean on) { paused = on; if (on) { pauseStarted = System.currentTimeMillis(); } else { pauseElapsed += System.currentTimeMillis() - pauseStarted; } } ... if (!paused) { millis = System.currentTimeMillis() - startTime - pauseElapsed; hours = millis / (1000 * 60 * 60); millis -= hours * (1000 * 60 * 60); minutes = millis / (1000 * 60); millis -= minutes * (1000 * 60); seconds = millis / 1000; } g.drawString("Time: " + hours + ":" + minutes + ":" + seconds, 300, 10); |
|
|
|
|
|
30
|
Game Development / Game Mechanics / Re: Networked bit of a client
|
on: 2012-01-03 22:01:37
|
sounds a lot like my system  cool 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
| public class Packets {
private static final int[] sizes = new int[256]; private static final Packet[] packets = new Packet[256]; static { packets[187] = new AttemptLogin(); sizes[187] = -1; packets[23] = new RemotePlayer(); sizes[23] = -1; packets[112] = new DrawingAction(); sizes[112] = -1; packets[83] = new ChatMessage(); sizes[83] = -1; packets[241] = new RegionRequest(); sizes[241] = -2; }
public static Buffer fragment; public static ISAAC decryptor;
public static void handle(Buffer buffer) { boolean decrypt = true; if (fragment != null) { buffer.insertStart(fragment.array()); fragment = null; decrypt = false; } while (buffer.remaining() > 0) { int opcode = buffer.getSigned(); if (decrypt) { if (decryptor != null) opcode -= decryptor.next(); } else { decrypt = true; } opcode &= 0xFF;
int size = sizes[opcode]; Packet packet = packets[opcode]; if (packet == null) { System.out.println("Non-existant packet: " + opcode); return; }
if (size == -1) { if (buffer.remaining() > 0) size = buffer.get(); else { fragment = new Buffer(2).put(opcode); buffer.clear(); System.out.println("Storing fragmented packet " + opcode + "."); return; } } else if (size == -2) { if (buffer.remaining() > 3) size = buffer.getInt(); else { fragment = new Buffer(2).put(opcode); buffer.clear(); System.out.println("Storing fragmented packet " + opcode + "."); return; } }
int remaining = buffer.remaining() - size;
if (remaining < 0) { fragment = new Buffer().put(opcode); if (sizes[opcode] == -2) fragment.putInt(size); else fragment.put(size); fragment.put(buffer.getBackingBuffer(), buffer.readPosition(), buffer.remaining()); buffer.clear(); System.out.println("Storing fragmented packet " + opcode + ", size " + fragment.writePosition() + "."); return; }
try { packet.execute(buffer, opcode, size); } catch (Exception e) { e.printStackTrace(); }
if (buffer.remaining() != remaining) { System.out.println("<Opcode:" + opcode + "> Expected: " + remaining +", Actual: " + buffer.remaining()); buffer.skip(buffer.remaining() - remaining); } } }
} |
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|