Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Everything posted by Gixugif

  1. I am aware that there is a bug, a 12 or 13 year old bug, that exists on Linux and probably other Unix based systems, that certain ways of detecting when a key is pressed or released do not function the way one would expect. I am also aware there are a few ways around this and I have gone so far to attempt to implement this solution that can be viewed here: http://stackoverflow.../4679195/596359 The problem is that this does not seem to fix anything. The first question someone will ask I believe I can anticipate. I placed this code in a ".java" file named "RepeatingKeyEventsFixer.java". This file is in "../src/com/example/". To use it in my code I have put the following lines at the beginning of my main() method: RepeatingKeyEventsFixer repeatingkeyeventsfixer = new RepeatingKeyEventsFixer(); repeatingkeyeventsfixer.install(); [color=#000000]Still, when I press down a key, it tells me it's being pressed down and held, but it will also say it is being released with just about the same frequency. Does anyone have any idea what I may have done wrong? I have also posted this on StackExchange with poor results. I'll post the link here in case the way I phrased things there could help any more: http://stackoverflow.../8948238/596359 [color=#000000]The following code is the code I am using to test if a key has been released or not. I appreciate the time any takes to consider my question. addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e){ processKey(e); } public void keyReleased(KeyEvent g){ processKeyReleased(g); } } ... private void processKeyReleased(KeyEvent g){ int keyCode = g.getKeyCode(); if(!isPaused && !gameOver){ if(keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_RIGHT){ System.out.println("released"); player.stopLooping(); } } }
  2. Thank you, I see how that works now. I mean to read through the solution when I get the chance to better understand it, but it seems this solution would still be rather troubling in the context I'm using it. Since writing this game is also meant to be a learning experience I'm trying to implement many things myself that higher-level libraries would otherwise take care of such as loading sounds and graphics, but taking a looking at lwjgl just for this may be the way to go and it may prevent problems later on too. Edit: Of course using this for my input here would require me to use it in other areas to, requiring a massive rewrite. I'm wondering if that update will be quicker and maybe even save me a lot more time in the long run, or if I can think of a nice solution for this using the method I was originally going with.
  3. BufferedImage = ImageIO.read(getClass().getResourceAsStream("/Images/player.gif")); The file getResourceAsStream is looking at definitely exists (it's a variable in the actual code, but I figure simpler to write it out here), but for whatever reason, "is" is null on the next line. I'm guessing there's something I don't understand about how this works, but anything I've read so far on the matter hasn't been at all helpful, so I would be thankful for anyone who can explain to me what's going on. I'm sure it's not an issue of where the file is located. My classes are in /src in the DreamGame folder, and as you can see, Images is in the Images folder.
  4. Oops, sorry, took a while for me to get back to this. Edited the line in the op a little bit, but shouldn't have made a functional difference. So the problem was it was looking for "/Images" in the bin directory when the contents of "/Images" were in bin, but not "/Images" itself. Changing the code to read "/player.gif" instead of "/Images/player.gif" fixed this.
  5. Gixugif

    Neural Network help. Sorry!

    Alright, that makes things a ton clearer. Now this really doesn't seem all that difficult. Thank you so much.
  6. So, not having been able to find help anywhere else, I come here looking to ask something about NNs when I see the thread complaining about all the NN threads recently. Haha, Oh well. Here's one more then. I have question about inputting data. The data is layed out in a text file just like this: 4.4,0.4,1.1,3.2,flower-name 5.5,1.2,7.7,6.3,flower-name 4.5,6.2,4.4,1.9,flower-name etc. ... Each line is a data point. Now, the backprop function accepts one int. I realize, unfortunately, that the answer is probably different in each case, but I'll at least start by asking: Would I enter each of the numbers in on the line separately? Like loop through backprop 4 times for each line (I almost positive that's not how it'd be done, but like I said, just trying to figure this all out), or do I average them all together or something? I'm already normalizing the values by the way, by dividing the number by the highest number in each column. Also, what about the flower-name? Surely that has to be taken into account somehow. Anyway, thanks, and I'll post more details if necessary (and I'm sure it will be)
  7. Gixugif

    Neural Network help. Sorry!

    Why, yes, as a matter of fact, that does make me feel much better. by backprop I just meant backpropogation error. I was provided with that, feedforward, and such. I guess what I have to do is implement an algorithm that uses those functions to classify irises. Anyway, thanks. That helps a little. I think I can figure out the rest of the way. Here's the backprop program I was talking about, if you're still wondering: http://cl1p.net/backprop
  8. Wow, somehow I missed that. Thanks so much for catching that.
  9. So, I just started trying to learn OpenGL, and the tutorial I'm following has me creating a simple window with a solid black background. When I try to run it, I get the error "Can't Create A GL Rendering Context." I did a search and it would seem this has to do with your video driver. Because it's such a simple thing to do though, I'd imagine it has to do with my coding, or maybe because I have integrated graphics? Since the code is basically just copied from the tutorial, it doesn't seem like that'd be the issue. If it helps, i'm using NeHe's tutorial.
  10. #include <windows.h> #include <gl\gl.h> #include <gl\glu.h> #include <gl\glaux.h> HGLRC hRC = NULL; HDC hDC = NULL; HWND hWnd = NULL; HINSTANCE hInstance; bool keys[25]; bool active = TRUE; bool fullscreen = TRUE; LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); GLvoid ReSizeGLScene(GLsizei width, GLsizei height) { if (height == 0) { height = 1; } glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,(GLfloat)width/(GLfloat)height, 0.1f, 100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } int InitGL(GLvoid) { glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); return TRUE; } int DrawGLScene(GLvoid) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); return TRUE; } GLvoid KillGLWindow(GLvoid) { if (fullscreen) { ChangeDisplaySettings(NULL, 0); ShowCursor(TRUE); } if (hRC) { if (!wglMakeCurrent(NULL, NULL)) { MessageBox(NULL, "Release of DC And RC Failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION); } if (!wglDeleteContext(hRC)) { MessageBox(NULL, "Release Rendering Context Failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION); }hRC = NULL; } if (hDC && !ReleaseDC(hWnd, hDC)) { MessageBox(NULL, "Release Device Context Failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION); hDC = NULL; } if (hWnd && !DestroyWindow(hWnd)) { MessageBox(NULL, "Could Not Release hWnd.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION); hWnd = NULL; } if (!UnregisterClass("OpenG", hInstance)) { MessageBox(NULL, "Could Not UnregisterClass.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION); hInstance = NULL; } } BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag) { GLuint PixelFormat; WNDCLASS wc; DWORD dwExStyle; DWORD dwStyle; RECT WindowRect; WindowRect.left = (long)0; WindowRect.right = (long)width; WindowRect.top = (long)0; WindowRect.bottom = (long)height; fullscreen = fullscreenflag; hInstance = GetModuleHandle(NULL); wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.lpfnWndProc = (WNDPROC) WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = "OpenG"; if (!RegisterClass(&wc)) { MessageBox(NULL, "Failed to Register The Window Class.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return FALSE; } if (fullscreen) { DEVMODE dmScreenSettings; memset(&dmScreenSettings, 0, sizeof(dmScreenSettings)); dmScreenSettings.dmSize=sizeof(dmScreenSettings); dmScreenSettings.dmPelsWidth = width; dmScreenSettings.dmPelsHeight = height; dmScreenSettings.dmBitsPerPel = bits; dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { if (MessageBox(NULL, "The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?", "NeHe G", MB_YESNO|MB_ICONEXCLAMATION)==IDYES) { fullscreen = FALSE; } else { MessageBox(NULL, "Program Will Now Close.", "ERROR", MB_OK |MB_ICONSTOP); return FALSE; } } } if (fullscreen) { dwExStyle = WS_EX_APPWINDOW; dwStyle = WS_POPUP; ShowCursor(FALSE); } else { dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; dwStyle = WS_OVERLAPPEDWINDOW; } AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); if (!(hWnd = CreateWindowEx( dwExStyle, "OpenG", title, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | dwStyle, 0, 0, WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top, NULL, NULL, hInstance, NULL))) { KillGLWindow(); MessageBox(NULL, "Window Creation Error.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return FALSE; } static PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, bits, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 }; if (!(hDC = GetDC(hWnd))) { KillGLWindow(); MessageBox(NULL, "Can't Create A GL Device Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return FALSE; } if (!(PixelFormat = ChoosePixelFormat(hDC, &pfd))) { KillGLWindow(); MessageBox(NULL, "Can't Find A Suitable PixelFormat", "ERROR", MB_OK | MB_ICONEXCLAMATION); return FALSE; } if (!(hRC = wglCreateContext(hDC))) { KillGLWindow(); MessageBox(NULL, "Can't Create A GL Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return FALSE; } if(!wglMakeCurrent(hDC, hRC)) { KillGLWindow(); MessageBox(NULL, "Can't Activate The GL Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return FALSE; } ShowWindow(hWnd, SW_SHOW); SetForegroundWindow(hWnd); SetFocus(hWnd); ReSizeGLScene(width, height); if (!InitGL()) { KillGLWindow(); MessageBox(NULL, "Initialization Failed.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return FALSE; } return TRUE; } LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_ACTIVATE: { if (!HIWORD(wParam)) { active = TRUE; } else { active = FALSE; } return 0; } case WM_SYSCOMMAND: { switch (wParam) { case SC_SCREENSAVE: case SC_MONITORPOWER: return 0; } break; } case WM_CLOSE: { PostQuitMessage(0); return 0; } case WM_KEYDOWN: { keys[wParam] = TRUE; return 0; } case WM_KEYUP: { keys[wParam] = FALSE; return 0; } case WM_SIZE: { ReSizeGLScene(LOWORD(lParam), HIWORD(lParam)); return 0; } } return DefWindowProc(hWnd, uMsg, wParam, lParam); } int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG msg; BOOL done = FALSE; if (MessageBox(NULL, "Would You Like To Run In Fullscreen Mode?", "Start Fullscreen?", MB_YESNO | MB_ICONQUESTION)== IDNO) { fullscreen = FALSE; } if (!CreateGLWindow("NeHe's OpenGL Framework", 640, 480, 16, fullscreen)) { return 0; } while(!done) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) { done = TRUE; } else { TranslateMessage(&msg); DispatchMessage(&msg); } } else { if (active) { if(keys[VK_ESCAPE]) { done = TRUE; } else { DrawGLScene(); SwapBuffers(hDC); } } if (keys[VK_F1]) { keys[VK_F1] = FALSE; KillGLWindow(); fullscreen = !fullscreen; if (!CreateGLWindow("NeHe's OpenGL FrameWork", 640, 480, 16, fullscreen)) { return 0; } } } } KillGLWindow(); return (msg.wParam); } It should be the same as what's on the site, but I suppose it's easier to see it all together, and maybe someone else will see something. I already had the latest driver from intel - I checked again to make sure. I have Win 7 so I tried disabling aero; that didn't help. I wasn't really able to find anything else on the intel pages that would help. I really appreciate all that help.
  11. Intel 82945G Express And yeah, I made sure it was fully updated.
  12. delOrder[count] = getData(infantCircle.deleteNode(infantCircle.getNode(k))); This should be all you need. All of the functions accept Node as their parameter and return a Node also. The error I get says it "cannot find symbol" at getData(), and it's probably because for some reason it doesn't think it's getting a Node as a parameter. Help would be appreciated. Thanks!
  13. Gixugif

    Java won't recognize function

    The method calling getData is in a different class. Yeah, that was it. Stupid little mistake, didn't even occur to me you couldn't do that for some reason. Thanks for the help, and very quick replies.
  14. Gixugif

    Java won't recognize function

    It's defined in the Circular_Linked_List class (not the one included in the java library), as getNode and deleteNode. I might as well include the definitions. public Node getNode(int index) // returns a node from the list { if (index > (size - 1)) return null; Node temp = getFirst(); for (int i = 0; i < index; i++) { temp = temp.next; } return temp; } public Node deleteNode(Node delNode) // deletes a node { int index = checkNode(delNode); if (index == -1) System.out.println("Node doesn't exist"); Node temp = getNode(index - 1); if(index == (size - 1)) { Node del = last; temp.next = last.next; last = temp; size--; return del; } else { Node del = temp.next; temp.next = temp.next.next; temp.next.next = null; size--; return del; } } public int getData(Node myNode) // returns data of node { return myNode.data; } Here's the error message after splitting it into four lines (it appears at getData): AmStramGram.java:64: cannot find symbol symbol : method getData(Circular_Linked_List.Node) location: class AmStramGram getData( ^ 1 error
  15. Gixugif

    Java error: cannot find symbol

    Oh, thank you. That did it. I didn't realize that variables declared in try...catch blocks were only available inside of them.
  16. [source lang = "java"] public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter number of nodes in the graph: "); try { int size = sc.nextInt(); } catch (IOException ioe) { System.out.println("IO exception occurred!"); System.exit(1); } int[][] graph = new int[size][size]; createGraph(graph, size); displayGraph(graph, size); } I'm just learning java, and unfortunately I'm finding input a tad bit more annoying than I do in other languages I'm more familiar with. While this is just my main funtion, the problem is the same in the others, so I figure only this one is necessary. Basically I'm receiving "cannot find symbol" errors for all of my variables, at least for the ones that use user input. And yes, I did import Scanner. Obviously I'm doing something wrong, but in the examples I've looked up, what was done is exactly what I'm doing, so I have no clue. Help would be appreciated.
  17. int FindFirstSet(unsigned BitMap, unsigned start) { unsigned Mask = (1 << start); while (Mask) { if (BitMap & Mask) return start; ++start; Mask <<= 1; } return -1; } I'm relatively new to C++ and out of curiosity I was browsing through Art of Assembly since I found it online for free and I'm just not sure what these two bits of code mean: 1 << start Mask <<= 1; I know "<<" is for the ostream normally, but I've never seen the symbols used like that before.
  18. Gixugif

    Unrecognized c++ symbols

    Oh okay, that makes lots of sense. Now that I actually know what they're called I can look them up too. Search engines really need to allow for the searching of symbols. Anyway, thanks for answering my question.
  19. I've been trying to put multiple background images on my website. On main one, that everything else rests on that scrolls with the screen, and then another one just to put the main content on, such as text, that is fixed. I've tried googling for answers and so far this is the most effective tag I've found, but as you can see it only shows the part of the image, depending on how much text there is (and it won't show the top at all, maybe because of the button placement?) <div style="background-image: url(http://gixugifsdomain.com/images/contentplatform.jpg); background-repeat: no-repeat; background-position: center"> I know you're probably supposed to do this in CSS, but when I tried it didn't work at all, using this tag: div.main { background: url('http://gixugifsdomain.com/images/backgroundplatform.jpg') center no-repeat fixed; } I am new at CSS though, and I really only know what w3schools.com says and then what I've had to looks up, so I'm sure I'm just doing something wrong with that. Anyway, I'd appreciate it if someone could tell me how exactly to do this. Here's a link to the main page of my website so you can see what I'm talking about. I've only put the second image on the main page for now. Main Site
  20. Maybe I'm misunderstanding, but if the problem is that it's assigned to a div in the first place, I don't see why assigning it to a central div would make any difference. Anyway, I did and the image doesn't show up at all then. Currently I have the center div you said to put in, and then I put back in the original one too, since it wasn't showing up at all.
  21. for (int i = 0; i < word.length(); i++) { if (&word == "<") { inTag = true; } else if (&word == ">") { inTag = false; } } Basically I'm feeding it an html document and so when it comes across a tag it should see the "<" symbol and recognize that it's looking at a tag, and when it reaches the end it'll see the ">" symbol and know the tag has been closed, and output the words not in tags into a separate file. I tested everything else and the string "word" is as it should be, and that should be the only factor affecting this.
  22. Gixugif

    Why won't my if statement work!?

    Wow, thank you so much. I totally forgot about the character literals thing. There's just so much to remember with C++.
  23. #include <iostream> #include <math.h> using namespace std; double popGrowth(double, double); ////////////////////////////////////////////////////// int main() { double townGrowth[3][3] = { {1.1, 0.3, 0.7}, {0.1, 1.2, 0.3}, {0.2, 0.6, 1.3} }; double initialUrban = 2.1, //million initialSub = 1.4, //million initialEx = 0.9, //million urban; urban = popGrowth(townGrowth, initialUrban); cout << urban; } ////////////////////////////////////////////////////// double popGrowth(double townGrowth[][3], double urban) { for (int i = 0; i < 3; i++) { urban = (urban * (pow(townGrowth[3], 50.0))); // x(t) = a * b ** (t/r) } return urban; } The error I receive is: PopulationGrowth.cpp: In function 'int main()': PopulationGrowth.cpp:29: error: cannot convert 'double (*)[3]' to 'double' for argument '1' to 'double popGrowth(double, double)' The program isn't nearly complete or anything, but I figured I'd test it to make sure things worked up to there and now I've been stuck with this error for some time. I've tried searching for the error message through google, but either the problems I found were different or the solution didn't work. Any ideas would be appreciated.
  24. Gixugif

    Noobish c++ question

    Just completely lost. I know it's something obvious, but I just don't see it. I want an array to be passed into a function where the user can input values for the array, but when I run the program, nothing happens. I've looked on many different sites and from what I've seen and know this should work. My mind is boggled. ///////////////////////////////////////////////////////// // Name: array.cpp // // Purpose: Create a static array, initialize its // // values, then display the values. // // Author: // // Date: February 25, 2009 // ///////////////////////////////////////////////////////// #include <iostream> #include <string> using namespace std; void initialize(int, int); void display(int, int); ///////////////////////////////////////////////////////// int main() { const int SIZE = 5; int array[SIZE]; void initialize(int array[], const int SIZE); void display(int array[], const int SIZE); } ///////////////////////////////////////////////////////// void initialize(int array[], int numValues) // Name: initialize(int array[], int numValues) // Purpose: initialize the elements of an array of size equal to numValues // Precondition: numValues is a positive (bigger than zero) value // Postcondition: all elements in the array will have the values entered // by the user { int arrayval = 0; for (int i = 0; i < numValues; i++) { cin >> arrayval; array = arrayval; } } void display(int array[], int numValues) // Name: display(int array[], int numValues) // Purpose: displays the elements of an array of size numValues // Precondition: numValues is a positive integer value; elements of the array // have been initialized before // Postcondition: elements of the array are unchanged // const int array[] says that the elements of the array cannot be changed // inside the display function { for (int i = 0; i < numValues; i++) cout << array << endl; } //////////////////////////////////////////////////////////
  25. Gixugif

    Noobish c++ question

    Well, that works. It makes me feel like an idiot for missing that stuff, but thanks for the help. I must have been looking at the code in the book and the webpages I checked incorrectly.
  • 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!