Show Posts
|
|
Pages: [1] 2
|
|
1
|
Game Development / Newbie & Debugging Questions / How to divy things up using threads
|
on: 2013-04-12 05:10:36
|
|
I'm sorry if this is a re-ask, but when trying to separate actions into threads, what should you consider, the only thing i can think of is that every variable affected, assuming this is a new thread not the main one running the game loop, must be declared volitile. Is that all that need to be done? and should the game update loop and render loop be on separate threads? ty for all help.
|
|
|
|
|
2
|
Game Development / Newbie & Debugging Questions / Render off screen
|
on: 2013-04-12 05:05:29
|
|
I'm not sure exactly how to phrase a search for this, but I don't understand how, java2D at least, handles this aspect of rendering or if it does at all. If you tell it to render an object wholly outside, or even partially outside, does it save itself the cpu and not render it at all? I mean the way I understand it, every one of those draw methods affects some matrix of pixels (I think of it as a 2D array), and then the show method is called and it is shown on the screen, is that correct?
|
|
|
|
|
5
|
Game Development / Newbie & Debugging Questions / lan games in java
|
on: 2013-01-31 07:22:57
|
Just wondering if anyone would know a good tutorial for lan networks in java, I understand sockets and the like, as well as the whole concept of doing say collision detection on one computer and sending the updated data to all the clients, but the only actual server and client java program I could find a tutorial for creates a server that crashes immediately after the client disconnects, I don't understand the (coding) difference between the tutorial he showed and a lan network program, or even whether or not his was already lan to begin with. Any tutorials or help would be nice, ty here is the code for that tutorial I found: server: http://pastebin.com/r9AdU2BYclient and dataPackage: http://pastebin.com/ahgRRhtW
|
|
|
|
|
6
|
Game Development / Newbie & Debugging Questions / Re: Multiplayer top down shooter
|
on: 2013-01-19 18:28:47
|
|
makes sense... so say when someone presses the button to shoot, should that player send a series of varriables or IDs needed to create the object on the server, or create the object and send it to the server (is that possible?), I assume the former, so after the server has the object(s), does it send the data for ALL of those objects to every player, or just ones that have changed?
|
|
|
|
|
7
|
Game Development / Newbie & Debugging Questions / Multiplayer top down shooter
|
on: 2013-01-19 17:49:46
|
|
As the title said, I am trying to make a multiplayer top down shooter, I get the gist of the client server model and java sockets, but I am unsure as exactly where to put them... What I mean is, a single player starts a server, then after every one links to it, what exactly should be sent to each player. Does every player only send their location to the server, location of any projectiles they fire, the ID of an enemy if they hit it? If someone has a link to a tutorial or something on the subject pls tell me. THX for ANY help!
|
|
|
|
|
8
|
Game Development / Newbie & Debugging Questions / Re: adjusting points for rotation
|
on: 2013-01-14 21:08:57
|
|
I wanted to be able to have the sword about 30 degrees to the right of where the character is facing, then after the mouse is clicked the sword swings around 90 degrees in the leftward direction. What I have in that bit of code is what I thought would work for a stationary sword, but it doesn't stay stationary (as I described in the previous post).
|
|
|
|
|
9
|
Game Development / Newbie & Debugging Questions / Re: adjusting points for rotation
|
on: 2013-01-14 10:06:30
|
Rotation matricies seem to be what I was looking for, but when I try to implement them (at the moment the sword is just a line), I just see the sword rotating from what looks like 90 degrees to 180 degress as fast as it can, and the sword itself is much longer than it should be, this is what pertains to the sword in the game loop: 1 2 3 4 5 6 7 8 9 10 11 12
| double subx = test.getXloc(); double suby = test.getYloc(); playerCenterX = test.getXloc() + (test.getWidth()/2); playerCenterY = test.getYloc() + (test.getHeight()/2); if(cooldown > 0) cooldown--; playerRot = Math.atan2(mouseY - playerCenterY, mouseX - playerCenterX); swordRot1 = playerRot; subx = sword.getX1(); suby = sword.getY1(); sword.setLine(subx*Math.cos(swordRot)-suby*Math.sin(swordRot),subx*Math.sin(swordRot)+suby*Math.cos(swordRot),sword.getX2(),sword.getY2()); |
|
|
|
|
|
11
|
Game Development / Newbie & Debugging Questions / Re: which is faster?
|
on: 2012-12-31 22:08:47
|
|
I read over that thread a bit, I love the idea of checking within a set rectangular grid, but it becomes a lot more complicated when you try to deal with sprites along the edges of any rectangle in the grid, because a single sprite can be in up to 4 at once (if its in the midddle of them)...
|
|
|
|
|
12
|
Game Development / Newbie & Debugging Questions / which is faster?
|
on: 2012-12-31 08:48:45
|
|
For collision detection, I can either find out whether or not 2 sprites are in the same rectangular areas (up to 4, since they can be on the edge) at the same time before doing collision detection, or simply check every sprite on the entire map every time. Can anyone tell me which they think would be optimum, or rather at what point (as in after how every many collision detections need to take place) does this start saving speed? Also which is faster == or >,<,<=, and >=?
|
|
|
|
|
13
|
Game Development / Newbie & Debugging Questions / Re: Enemy rotation and following wonky...
|
on: 2012-11-30 06:51:16
|
|
I get how to do that, I usually do something along these lines:
if(subb.getCenterX()>=sube.getX()&&subb.getCenterX()<=(sube.getX()+sube.getWidth())&&subb.getCenterY()>=sube.getY()&&subb.getCenterY()<=(sube.getY()+sube.getHeight()))
which is just checking whether or not a point is within a rectangular area, but I know methods that check whether or not, for example, a circle and rectangle intersect. I have no idea how they check within the area of a circle like that as well as other irregular shapes.
|
|
|
|
|
14
|
Game Development / Newbie & Debugging Questions / Re: Enemy rotation and following wonky...
|
on: 2012-11-27 09:53:53
|
|
I need to brand STUPID in big bold letters on my forehead, ty for finding that. While I'm here though do you know of a way to rotate the rectangles points, because it is only rotated when its drawn and this doesn't work for hit detection, heck even if i knew how to rotate the 4 corners of the rectangle I wouldn't know of a method to check whether or not something is within that area...
|
|
|
|
|
15
|
Game Development / Newbie & Debugging Questions / Enemy rotation and following wonky...
|
on: 2012-11-27 07:51:04
|
Attempting to make enemies turn and follow player, but they all seem to... I'm not sure, they rotate in the general direction of the player, but at times they go off on their own. The way I organized my classes is horrendous, but I wanted to throw something together to test and see if I could do something like this... apparently not. I'm Posting the whole code here: http://pastebin.java-gaming.org/b5fd1362b3fbut I know it has to be something wrong with the rotation I use, here is where I update the enemies: 1 2 3 4 5 6 7
| for(Move sube: enemies) { sube.setRot(Math.atan2(playerCenterY - sube.getCenterY(), playerCenterX - sube.getCenterY())); sube.setXloc(sube.getX() + (ENEMY_SPEED * Math.cos(sube.getRot()))); sube.setYloc(sube.getY() + (ENEMY_SPEED * Math.sin(sube.getRot()))); } |
Am I calculating the rotation wrong? any help is appreciated
|
|
|
|
|
16
|
Game Development / Newbie & Debugging Questions / fast algorithms
|
on: 2012-09-10 08:36:26
|
|
Ok I have a situation where one character must test whether they collide with any other characters or debris, so far I have done this by testing whether or not the characters rectangle intersects another character or debris' rectangle. As you can imagine this will become very big as more characters are added into a game, so I wonder if there is an algorithm that would handle this more effectively? Any kind of link to a site or book that has other algorithms useful to game development would be nice as well.
Ty for any and all help.
|
|
|
|
|
17
|
Game Development / Newbie & Debugging Questions / Re: double buffering fail...
|
on: 2012-07-27 06:02:49
|
|
Descended Rupture actually extended regular frame (no swing at all) I was paranoid about the EDT so I didn't use swing at all... Also I tried adding a (1,1) grid layout to the frame (DescendedRupture) then added the base panel, base.getWidth() still returned 0, I tried setting its layout to null (just in case, even though I think it is null by default) then adding the base panel, and using base.setBounds(), no matter what I set its width and height to in setBounds, base.getWidth() still returned 0. I don't know what to make of it, but thankfully I could get around it because a canvas was on top of base, and its getWidth() and getHeight() methods worked.
|
|
|
|
|
18
|
Game Development / Newbie & Debugging Questions / Re: double buffering fail...
|
on: 2012-07-25 00:28:29
|
THANK YOU FOR FINDING THAT!?!!!!!!  It actually paints now, THANK U SOOO MUCH! holy crap 0_0 it does, why does base.getWidth() return 0... I have another class called GPanel that uses that method (it extends panel) and while inside GPanel (this.getWidth()) the method returns correctly, but then when its used in another class (and base.getWidth() is called) it returns 0. Why the heck does it do that?
|
|
|
|
|
19
|
Discussions / General Discussions / Re: Populated IRC
|
on: 2012-07-24 22:07:31
|
The question I am trying to answer has been on the forum for several days, I get that people don't want to dig through my code, I'm not going to ask (just give the option), but there are a series of questions about how I formatted my code that would be easier to address in a chat. PS here is where my question was http://www.java-gaming.org/topics/double-buffering-fail/26902/view.htmlalso teletubo, that forum is much more populated, but its supposed to be for lwjgl, so when I ask about pure java stuff like double buffering most people aren't willing to answer (understandably so), Also Ironically enough I found out about this forum from that channel... How do I get to the ##java irc channel?
|
|
|
|
|
20
|
Discussions / General Discussions / Populated IRC
|
on: 2012-07-24 21:48:15
|
|
I know the site has its own IRC channel, but I was wondering if anyone could tell me what time it is generally... active? Its just I haven't seen more then two people besides me on there the last couple of times I logged in, and I was wondering if it was always like this? If so could anyone tell me a more active IRC channel? Ty for any help.
|
|
|
|
|
21
|
Game Development / Newbie & Debugging Questions / double buffering fail...
|
on: 2012-07-20 18:08:05
|
Ok... I was attempting to make a 2D game, but for some odd reason double buffering isn't working. I have used it in several other programs and set it up the same way here, but here it doesn't work. In the other programs the code was shorter and only one or two Images were being loaded. This program loads all the images at launch, adds all componets, sets up double buffering, but right after this I tell it to change the canvas background color to blue, screen stays white. I tell it to run the game loop (which at this point only paints parts of the background) and it does nothing. I checked with a println() to see if the Images finished loading (they did), so i just don't know why it wont work. the code is here: http://pastebin.com/h1T4beYWIf your unwilling to look through the whole code (understandable its long), pls just tell me any Ideas you have on what might cause double buffering to not work. pls feel free to correct me if I'm doing anything horridly ineffecient or unneccesary (because I'm sure I have), Ty for any help.
|
|
|
|
|
23
|
Game Development / Newbie & Debugging Questions / null pointer exception (with rectangles)
|
on: 2012-07-17 16:35:52
|
I have allways assumed that this exception occurs when memory is not allocated for an array before it is used. Now after I added the code that alocated the memory where it was needed, it still threw the exception, so I added lines 7-15 to this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| public void setOutline(int aniID, int x, int y, int w, int h) { xloc = x; yloc = y; width[aniID] = w; height[aniID] = h; try { outline[aniID].setRect(x,y,w,h); } catch(NullPointerException exc) { outline = new Rectangle[width.length]; outline[aniID].setRect(x,y,w,h); } } |
and lo and behold it is still throwing the same exception (now coming from line 14) after memory was allocated on the previous line. How is this happening, Ty for any help?
|
|
|
|
|
24
|
Game Development / Newbie & Debugging Questions / Re: Array out of bounds error
|
on: 2012-07-12 20:41:11
|
|
ok ultroman, I tried something almost exactly like the code in post 14, it still threw the exception... but it may have been the way I did it, I was on stupid pills that day. Also, those casts are very... unnecessary, but the whole code was just so I could learn active rendering, and see how well i could do with AI. I learned enough to improve it quite a bit (I hope), I really missused inheritance when I made the Blue/RedStick classes. Ty all for the help!!
|
|
|
|
|
28
|
Game Development / Newbie & Debugging Questions / transparent colors
|
on: 2012-07-11 12:45:31
|
You know how every image in java (or anywhere else) has to be square? You have some kind of background in the places where you didn't draw (white or otherwise), so how do you turn that transparent/opaque in java? I tried drawing the image in photoshop with an opaque background, and it was still drawn white. Then google showed me this (found at http://stackoverflow.com/questions/665406/how-to-make-a-color-transparent-in-a-bufferedimage-and-save-as-png): 1 2 3 4 5 6 7 8 9 10 11 12
| public Image transformGrayToTransparency(BufferedImage image) { ImageFilter filter = new RGBImageFilter() { public final int filterRGB(int x, int y, int rgb) { return (rgb << 8) & 0xFF000000; } }; ImageProducer ip = new FilteredImageSource(image.getSource(), filter); return Toolkit.getDefaultToolkit().createImage(ip); } |
What I really don’t understand is lines 5-8, namely the return statement, because 1) I don’t understand its logic or the purpose of that hexadecimal number, and 2) how is rgb 1 integer? If there is a simpler way to do what I need without the use of this code, please tell me.
|
|
|
|
|
29
|
Game Development / Newbie & Debugging Questions / Re: Array out of bounds error
|
on: 2012-07-11 12:33:09
|
For some odd reason it is still throwing an exception. i had to change the code slightly: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| Iterator<BlueStick> iterb = bluep.iterator(); while(iterb.hasNext()) { BlueStick subb = iterb.next(); if(subb.isDead()) { iterb.remove(); } } Iterator<RedStick> iterr = redp.iterator(); while(iterr.hasNext()) { RedStick subr = iterr.next(); if(subr.isDead()) { iterr.remove(); } } |
I have no idea why its still doing that, I'm also curious why this code also throws the exception: 1 2 3 4 5 6 7 8 9 10 11 12 13
| for(int x=0;x<bluep.size();++x) { if(x==(bluep.size()-1)) break; BlueStick subb = (BlueStick)bluep.get(x); if(subb.isDead()==true) { bluep.remove(x); } } |
if it allways breaks out of the for loop on the very last object in the arraylist (before it has a chance to delete it), how is it still accessing past the bounds of the arraylist??? also here is the error code when I tested the iterator (just in case it matters): Exception in thread "Thread-4" java.lang.IndexOutOfBoundsException: Index: 4, Size: 4 at java.util.ArrayList.rangeCheck(ArrayList.java:604) at java.util.ArrayList.get(ArrayList.java:382) at GamePanel.updateGame(GamePanel.java:425) at GamePanel.gameLoop(GamePanel.java:145) at GameFrame$1.run(GameFrame.java:127)
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|