Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Everything posted by Funkapotamus

  1. Funkapotamus

    Dealing with (annoying) people (and their code)

    @lefthandman: This sounds a lot like my experience with other programmers in college. Only your peers seem a lot more knowledgeable- probably because my fellow students mostly stayed out of the contest coding scene. Contests aside, I have noticed that programmers these days are developing a competitive nature about them. Venturing out on a limb here, I would guess this is because programmers tend to be nerdy. Thus, they have little to socially 'show off' outside of of their programming prowess. I'm guilty of this to an extent; I'm just not a douche about it. The worst thing for me to deal with was the fact that professors and other students gave them praise for their arrogance- thinking that these guys had so much raw knowledge. Of course, this only fueled their behavior, and the cycle continued. Theories aside, I'll tell you how I dealt with it: I ignored them. I ignored them, continued to teach myself game programming, and let them agonize over their big-o notation ego-parties. The result? I've been a professional game programmer since college. They have either become Java codemonkeys (nothing against Java- I love it, but don't ever get to use it!), or they are unemployed due to not being able to program on a professional level. So my advice is to ignore them. Don't remove yourself from the social scene however. Just ignore them when they start exhibiting bad behavior. I guess I'd treat it like training a dog without negative reinforcement.
  2. There's nothing wrong with using the keyword 'this' in the circumstance you describe. It's difficult to tell with the given information. I did notice one thing however: Your length may change each iteration. Did you perhaps mean "this.arr.length" instead of "this.arr.length"?
  3. Quote:Original post by Wyrframe Castle Crashers is a side-scrolling beat'em'up, like GoldenAxe, River City Ransom, Double Dragon, et al. ahlex; this means you are essentially working with 3D, not 2D. There is an X coordinate which maps naturally to the X screen coordinate, a Y coordinate which maps to near/far on the combat "stage", and a Z coordinate which maps to vertical distance off the "floor" of the combat "stage". Thus; movement is done in the XY plane as normal, and when you jump your Z coordinate will vary with altitude. When drawing, of course, you can use pure-2D graphics because Y and Z are parallel once projected into screen space. There is no Z axis in games like Golden Axe and Castle Crashers. The Y axis serves as a measure of depth into the screen, and as height from a given depth. Collision is considered vs. objects within a certain threshold of your Y translation. Jumping is a temporary offset on the Y axis and does not effect your character's Y translation in regards to collision. Thus, the further your depth, the higher your Y translation. Likewise, the higher you jump, the higher your Y translation.
  4. You see, ahlex, all you need to do is implement a quaternion-tree system. This left-first translation system provides a functional solution that doesn't result in that nasty static quad-tree gimbal lock other systems are known for. Don't forget to use reinterpret_cast on your vectors too, that speeds up movement in multiple directions.
  5. I suspect your game is running sluggish due to transparency settings of the image. Look into the transparency returned in image.getColorModel().getTransparency() when you change your image format. Your flicker can probably be fixed by poking around Component.Update(Graphics g) and Component.Repaint(). If I recall, the window will catch movement events and attempt to redraw itself. However, since you're manually setting the graphics each frame, it's left to you to do the redrawing as well. I should warn: It has been a while since I did anything game related with Java. Or rather, anything with Java at all. Though the specifics may be off, I'm pretty sure that I'm pointing you in the right direction.
  6. I'm sure discussion about the legality of recreating video games or other intellectual content has been brought up ad infinitum. I apologize if this is old news, however, I believe this is a special case. The game, as the title suggests is Magic: The Gathering. The goal would be to recreate the online version of the table-top card game. Now, right there is the special case: we're dealing with two entities: 1) MTG - The card game 2) MTG:O - The computer game I know for certain that recreating board games is in fact legal. Just so long as certain conditions are met. For example, the board game Settlers of Catan has been recreated with no ill legal troubles. Microsoft's Settlers of Catan Online: http://zone.msn.com/en/catanonline/default.htm Freeware: http://www.jsettlers.com/ The conditions are something along the lines of: -No intellectual content can be used (pictures/descriptions) -No terminology can be used (must rename game pieces) If MTG were simply a card game (which I'm perhaps incorrectly considering a "board game"), I would feel confident suggesting someone attempt to recreate it. However, because it has an online portion, I am on curious legal ground. For the record: This would be a non-for-profit project I'm suggesting to an old friend- to challenge some of his bright students with. I'm assuming they'd want to distribute the finished project in some way.
  7. Funkapotamus

    Legality of recreating MTG:O

    In that case, wouldn't the blame simply be shifted from the card game developer, to the party that created the plugin? If someone makes a Half-Life mod that spoofs Halo, then Valve wouldn't get in trouble. I suppose that's why makers of such tools offer disclaimers and license agreements. Such that you can use their app and tools to create whatever you like, so long as you're not stepping on something else's toes.
  8. Funkapotamus

    Legality of recreating MTG:O

    Hey cool, Sloper replied to me. Thanks for the replies- though I think some of you were taking too many liberties with your assumptions. I only post as a means to cover my butt. I'd rather not suggest somebody do a project that would get them in a world of trouble. However, it seems that as long as things are kept on a purely academic level, there's no harm.
  9. This post is a continuation of the wonderful thread started by C-Junkie found here: http://www.gamedev.net/community/forums/topic.asp?topic_id=284259 Thanks to that thread, I was able to get SDL_ttf up and running. However, I was disappointed by the method's speed. Creating, binding, blitting, and freeing a new OpenGL texture for each string of output was hurting framerate. So, I combined it with the good old .bmp font/display list method. This will load a .ttf font using SDL_ttf, and make a 512x512 pixel texture that contains every character from ascii value 32 to 128. It then builds display lists for each character so you can render text just like you would via the traditional .bmp font method. See a picture of it here. Code: const int OFFSET = 32; const int MAX_ASCII = 128; TTF_Init(); TTF_Font* font = TTF_OpenFont("arial.ttf", 40); // it's best to set the width to the size of the font specified above float charWidth = 40; // make the height a little bit higher since we'll be auto aligning letters that go above/below the baseline and they may trail over float charHeight = 50; // characters are very small. it's best to make the font large and scale it down rather than make it small and blow it up float textureWidth = 512; float textureHeight = 512; /* create letters */ // set letter color to white SDL_Color color = { 255, 255, 255, 255 }; // create glyphs, from ' ' (space) to '~' (tilde) std::vector<SDL_Surface*> glyphCache; for(int i = OFFSET; i < MAX_ASCII; i++) glyphCache.push_back(TTF_RenderGlyph_Blended(font, i, color)); /* create destination surface */ SDL_Surface* destination = SDL_CreateRGBSurface(SDL_SWSURFACE, (int)textureWidth, (int)textureHeight, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); /* blit glyphs onto destination */ SDL_Rect glyphRect; int row = 0; // 10 chars per row int col = 0; for(int i = OFFSET; i < MAX_ASCII; i++) { int minx, maxx, miny, maxy, advance; TTF_GlyphMetrics(font, i, &minx, &maxx, &miny, &maxy, &advance); glyphRect.x = (int)(col * charWidth); glyphRect.y = (int)(row * charHeight + TTF_FontAscent(font) - maxy); SDL_BlitSurface(glyphCache[i - OFFSET], 0, destination, &glyphRect); if(col >= 10) { col = 0; row++; } else col++; } /* create texture */ glGenTextures(1, &textureId); glBindTexture(GL_TEXTURE_2D, textureId); glTexImage2D(GL_TEXTURE_2D, 0, 4, (int)textureWidth, (int)textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, destination->pixels); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); /* create display lists */ GLuint* chars = new GLuint[MAX_ASCII]; int* charWidths = new int[MAX_ASCII]; row = 0; col = 0; for(int i = 0; i < MAX_ASCII; i++) { int id = glGenLists(1); chars = id; int minx, maxx, miny, maxy, advance; TTF_GlyphMetrics(font, i + OFFSET, &minx, &maxx, &miny, &maxy, &advance); float minX = charWidth * col / textureWidth; float maxX = (advance) / textureWidth + minX; float minY = charHeight / textureHeight * row; float maxY = minY + charHeight / textureHeight; charWidths = advance; glNewList(id, GL_COMPILE); glBegin(GL_QUADS); glTexCoord2f(minX, maxY); glVertex2f(0.0f, 0.0f); glTexCoord2f(maxX, maxY); glVertex2f(advance, 0.0f); glTexCoord2f(maxX, minY); glVertex2f(advance, charHeight); glTexCoord2f(minX, minY); glVertex2f(0.0f, charHeight); glEnd(); glTranslatef(advance + 1, 0.0f, 0.0f); glEndList(); if(col >= 10) { col = 0; row++; } else col++; } /* free/kill everything */ for(unsigned int i = 0; i < glyphCache.size(); i++) SDL_FreeSurface(glyphCache); SDL_FreeSurface(destination); TTF_Quit(); /* .... */ /* Get the char's list */ GLuint getList(char c) { return chars[c - OFFSET]; } /* ... */ /* Usage */ string msg = "Do a barrel roll!"; for(unsigned int i = 0; i < msg.length(); i++) glCallList(getList(msg.c_str())); You'll note I store the width of each character in "int* charWidths". Using this information, it'd be very easy to display text that's centered at a given position, or left/right justified.
  10. Funkapotamus

    (flower blooming) done...code inside

    Googling "draw ellipse opengl" brings up the answer... Or, you could draw a circle (also very easily googled) and scale one axis.
  11. Funkapotamus

    Best field of view (FOV) for 2D polygon games

    This will make an OpenGL unit on the plane Z = -256 equal one pixel. It also makes it so vertex(-screenWidth, -screenHeight, -256) is the bottom left of your window, and vertex(screenwidth, screenHeight, -256) is the upper right of your window. glViewport(0, 0, screenWidth, screenHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-screenWidth / 64.0f, screenWidth / 64.0f, -screenHeight / 64.0f, screenHeight / 64.0f, 8, 65536); glMatrixMode(GL_MODELVIEW); So, if you wanted to draw a 100x100 pixel quad: glTranslatef(0.0f, 0.0f, -256.0f); glBegin(GL_QUADS); glVertex(-50.0f, -50.0f, 0.0f); glVertex(50.0f, -50.0f, 0.0f); glVertex(50.0f, 50.0f, 0.0f); glVertex(-50.0f, 50.0f, 0.0f); glEnd(); Using Gradius as an example, the ship would be drawn at vertex(shipX, shipY, -256), the hud would be drawn in ortho mode, and the 3d background would be drawn at Z = -500 or so.
  12. There's some .dll's you need to add to your "c:\program files\jreX.X.X\bin folder". They should be located in the LWJGL zip file It also couldn't hurt to move the LWJGL jars into "c:\program files\jreX.X.X\lib\ext". It might not be necessary, though I don't know how Netbeans adds external libraries. In Eclipse you don't have to move the jars. (psst! Eclipse > Netbeans! :)
  13. Funkapotamus

    Help with texture mapping [newbie]

    Don't forget to enable textures!: glEnable(GL_TEXTURE_2D) I've forgotten to do that many times to great and embarrassing frustration.
  14. Funkapotamus

    Lua with C++

    What does "print the name of all the functions that have the document" mean? Can you rephrase the question? Are you looking for a simple hello world tutorial for newer lua versions? It's pretty simple: // 5.1 setup lua_State* lua = luaL_newstate(); luaL_openlibs(lua); // open file char* file = "test.lua"; luaL_loadfile(lua, file); // execute lua_pcall (lua, 0, LUA_MULTRET, 0); // close lua_close(lua);
  15. Funkapotamus

    Large values of glLineWidth require normals?

    If framerate/vsync were the issue then adding normals wouldn't have an effect, correct? My FPS is just fine- I haven't noticed any slowdown or tearing otherwise. Lines drawn by glPolygonMode just tear or fray when I view them from different angles. *shrugs*
  16. "my agent isn't even wandering along the straight path between the start and end points" If you use the equation I provided, he should move along a straight path. If you fear that you are returning an improper angle, try this: public int vectorToAngle(Vector src, Vector dest) { int quadrant = -1; if(dest.x == src.x && dest.y == src.y) return 0; else if(dest.x >= src.x && dest.y >= src.y) quadrant = 0; else if(dest.x <= src.x && dest.y >= src.y) quadrant = 3; else if(dest.x <= src.x && dest.y <= src.y) quadrant = 2; else quadrant = 1; int angle = (int)Math.toDegrees(Math.atan((Math.abs(dest.y - src.y) / Math.abs(dest.x - src.x)))); return angle + quadrant * 90; }
  17. I'm a bit confused as to what you're trying to do here. If you simply want to move the agent towards the destination, then the math is a little different. Pseudocode: // given Vector agentSrc; Vector agentDest; Vector diff; float speed; // move diff = agentDest - agentSrc; diff.normalize(); agentSrc += diff * speed; [Edited by - Funkapotamus on August 15, 2006 2:11:46 PM]
  18. Funkapotamus

    [java] Dear Java

    Care to devulge why you two split? I'm curious... and perhaps also on the fringe!
  19. 1) You could create static methods in the 3rd class to gain access to it anywhere. 2) You could setup methods in the second class to return a reference to the third. 3) You can reference 'public static' data members by referring to the class name public class ClassOne { public static void main(String[] args) { ClassTwo two = new ClassTwo(); // Option 1 - Static System.out.println(ClassThree.getValueStatic()); // Option 2 - By reference ClassThree three = two.getClassThree(); System.out.println(three.getValue()); // Option 3 - Static by name System.out.println(ClassThree.value(); } } public class ClassTwo { private ClassThree three; public ClassTwo() { three = new ClassThree(); three.setValue(100); } public getClassThree() { return three; } } public class ClassThree { public static int value = 0; public ClassThree() {} public void setValue(int value) { this.value = value; } public int getValue(){ return value; } public static int getValueStatic() { return value; } } It depends on what you're trying to do. Generally, you'd want to do things the second way unless you have a good reason to need the others. It's very easy to write terrible spaghetti code if you start referencing static members from all over the place.
  20. Funkapotamus

    [java] Java SE 6.0 Scripting

    I think some things got broken in recent builds. The source for the "Java" scripting engine (not "javascript") refers to things which don't exist anymore. Although, it might just be me. I may have messed up because the documentation is poor. Has anyone gotten the Java Engine to work? You can find it in the extra engines pack at scripting.dev.java.net. It'd be really really nice to make a Quake-Like console without needing to write a command parser :) Update: Ok, I figured it out. The packages at scripting.dev.java.net are outdated with 6.0 beta 2. I downloaded the source from the CVS and found that things were referring to classes and methods which don't exist anymore. I patched things up mostly, but there are issues getting the current JavaCompiler instance from javax.tools. In the meantime, javascript isn't a terrible option. You can interface with outside classes like this: public class ScriptTest { public ScriptTest() { ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine scriptEngine = manager.getEngineByName("JavaScript"); String packageName = this.getClass().getPackage().getName(); try { scriptEngine.eval("importPackage(" + packageName + ");"); scriptEngine.eval("ScriptTest.saySomething(\"Hello World\");"); } catch(ScriptException ex) { ex.printStackTrace(); } } public static void saySomething(String msg) { System.out.println(msg); } public static void main(String[] args) { new ScriptTest(); } } [Edited by - Funkapotamus on August 2, 2006 1:55:43 PM]
  21. Funkapotamus

    [java] OpenGL question...

    Assuming you have an array/buffer containing the texture's pixel data, you can do something like this. It isn't perfect, but it should set you on the right track. int[] pixelData; BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); glReadPixels(startX, startY, width, height, GL_BGRA, GL_UNSIGNED_BYTE, pixelData); int counter = 0; for(int x = 0; x < width; x++) for(int y = 0; y < height; y++) image.setRGB(x, y, pixelData[counter++]); ImageIO.write(image, ".jpg", new File("newFile.jpg");
  22. Funkapotamus

    VBO Size Questions

    The size of the struct shouldn't have any effect over the size of the VBO on the card. Or am I misunderstanding the reason behind making the struct a certain size? Actually though, I'm using Java so I can't use structs. I hope I wasn't confusing anyone with my "array math" example. To put it another way, I was wondering if the size is important due to data transfer or data storage. For example, when I use glVertexPointer(), should the pointer be 6-8 megs? If so, this would imply that it's better to transfer 6-8 megs to the card at a time. If the whole VBO must be 6-8 megs (glVertexPointer, glTexCoordPointer, etc), then it tells me that the card prefers storing VBOs in chunks of 6-8 megs.
  23. If you're drawing everything to the same plane, then then you'll want to draw the quad first. You may be able to get away with drawing the other primitives closer to the camera. In which case you can draw in any order you want. However, it's better practice to draw your background, then draw your objects, then draw your text/hud-type elements. I'm assuming you're going to want the full-screen quad to be your background- so I'd draw that first.
  24. glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); GL11.glFrustum(-width / 64.0f, width / 64.0f, -height / 64.0f, height / 64.0f, 8, 65536);Where width/height is your resolution. To draw a fullscreen quad: glTranslatef(-width / 2.0f, -height / 2.0f, -256.0f); glBegin(GL_QUADS); glVertex3f(-width / 2.0f, -height / 2.0f, 0.0f); glVertex3f(width / 2.0f, -height / 2.0f, 0.0f); glVertex3f(width / 2.0f, height / 2.0f, 0.0f); glVertex3f(-width / 2.0f, height / 2.0f, 0.0f); glEnd();
  25. Funkapotamus

    camera class design

    I posted code from my camera class a while ago. Here's the post: http://www.gamedev.net/community/forums/topic.asp?topic_id=335056&whichpage=1� It's basically straight out of Quake's source.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!