• What do you need help with? Version 5
    5,752 replies, posted
Ok, so creating a spatial tree following this tutorial : [Url]http://conkerjo.wordpress.com/2009/06/13/spatial-hashing-implementation-for-fast-2d-collisions/[/Url] When children are added to the stage, they are pushed into the correct vectors however I can't retrieve the vectors, only the first entry. Here's my Code (AS3): Actions (Frame): [code] import quadtree; var child; var grid = new quadtree(); stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler); function keyDownHandler(event : KeyboardEvent):void { child = new cube(); stage.addChild(child); child.x = mouseX; child.y = mouseY; grid.insert(child); for (var i:int = 0; i < 20; i++) { for (var j:int = 0; j < 20; j++) { trace(grid.retrieve(i,j)); } } } [/code] quadtree.as [code] package { public class quadtree { private var a = {p:5}; private var shift = 7; public var node = new Vector.<Vector.<Object>>(20 << shift, true); public function clearNode():void { for (var x:int = 0; x < 20; x++) { for (var y:int = 0; y < 20; y++) { node[(x << shift) | y] = new <Object> [null]; } } } public function retrieve(x:int, y:int):Vector.<Object> { return node[(x << shift) | y]; } public function insert(ref:Object):void { var u = ref.x / 30 | 0; var v = ref.y / 30 | 0; node[(u << shift) | v] = new <Object> [ref]; } public function quadtree() { } } } [/code] *Yes I know its not a quad-tree, changed plans but not file names...* The retrieve function is returning an object so trace(grid.retrieve(i,j)[k]) doesn't work.. Sorry If this is a stupid question its 3:00 AM here and I'm struggling to think.
[del]I have this square grid and I have a simple formula to get the centre of it, but I don't know how I'd go about getting the centre of an even rectangular grid.[/del] I seemed to have solved it, but I don't think the way I did it was very efficient.
[QUOTE=vexx21322;35185771][del]I have this square grid and I have a simple formula to get the centre of it, but I don't know how I'd go about getting the centre of an even rectangular grid.[/del] I seemed to have solved it, but I don't think the way I did it was very efficient.[/QUOTE] gridwidth/2*tilewidth?
Got a problem with this applet, no idea what is wrong. Could someone please troubleshoot? It's just supposed to be a simple code that asks for two coordinates, calculates its length, then draws them [code]/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package lab1_5; /** * * @author seni0020 */ import java.awt.*; import javax.swing.JApplet; import java.util.Scanner; import java.lang.Math; public class Lab1_5 extends JApplet{ public void init() { setSize(400,300); } public void paint(Graphics page) { Scanner scan = new Scanner (System.in); int x1, y1, x2, y2, length; System.out.println("Enter the x-value for the first point:"); x1 = scan.nextInt(); System.out.println("Enter the y-value for the first point:"); y1 = scan.nextInt(); System.out.println("Enter the x-value for the second point:"); x2 = scan.nextInt(); System.out.println("Enter the y-value for the second point:"); y2 = scan.nextInt(); System.out.println("The line is: (" + x1 + ", " + y1 + " ) to (" + x2 + ", " + y2 + " )"); length = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)); System.out.println("The length of the line is:" + length); page.setColor (Color.black); page.fillRect (0, 0, 400, 300); page.setColor (Color.white); page.drawLine (x1, y1, x2, y2); } } [/code] [b]Edit:[/b] No need, figured it out
2D collision has always been a pain for me. Is there a non hacky tutorial or even code on good 2D collision detection and resolution?
I apologize if I'm posting in the wrong section, but I am attempting to compile a new HL2 npc .cpp file for a mod, and I'm getting this clusterfuck of errors. [code] ------ Build started: Project: Server Episodic, Configuration: Debug Win32 ------ Build started 3/18/2012 6:52:16 PM. InitializeBuildStatus: Touching ".\Debug_episodic\Server Episodic.unsuccessfulbuild". ClCompile: All outputs are up-to-date. npc_conscript.cpp d:\insolence\src\game\server\npc_conscript.cpp(249): error C2374: 'gm_SchedLoadStatus' : redefinition; multiple initialization d:\insolence\src\game\server\npc_conscript.cpp(87) : see declaration of 'gm_SchedLoadStatus' d:\insolence\src\game\server\npc_conscript.cpp(249): error C2086: 'CAI_ClassScheduleIdSpace CNPC_Conscript::gm_ClassScheduleIdSpace' : redefinition d:\insolence\src\game\server\npc_conscript.cpp(87) : see declaration of 'gm_ClassScheduleIdSpace' d:\insolence\src\game\server\npc_conscript.cpp(249): error C2374: 'gm_pszErrorClassName' : redefinition; multiple initialization d:\insolence\src\game\server\npc_conscript.cpp(87) : see declaration of 'gm_pszErrorClassName' d:\insolence\src\game\server\npc_conscript.cpp(249): error C2084: function 'CNPC_Conscript::CScheduleLoader::CScheduleLoader(void)' already has a body d:\insolence\src\game\server\npc_conscript.cpp(87) : see previous definition of '{ctor}' d:\insolence\src\game\server\npc_conscript.cpp(249): error C2084: function 'bool CNPC_Conscript::LoadSchedules(void)' already has a body d:\insolence\src\game\server\npc_conscript.cpp(87) : see previous definition of 'LoadSchedules' d:\insolence\src\game\server\npc_conscript.cpp(249): error C2084: function 'bool CNPC_Conscript::LoadedSchedules(void)' already has a body d:\insolence\src\game\server\npc_conscript.cpp(87) : see previous definition of 'LoadedSchedules' d:\insolence\src\game\server\npc_conscript.cpp(249): error C2086: 'CAI_LocalIdSpace CNPC_Conscript::gm_SquadSlotIdSpace' : redefinition d:\insolence\src\game\server\npc_conscript.cpp(87) : see declaration of 'gm_SquadSlotIdSpace' d:\insolence\src\game\server\npc_conscript.cpp(249): error C2084: function 'const char *CNPC_Conscript::SquadSlotName(int)' already has a body d:\insolence\src\game\server\npc_conscript.cpp(87) : see previous definition of 'SquadSlotName' Build FAILED. Time Elapsed 00:00:08.45 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== [/code] Can anybody tell me how to fix this?
Need to post npc_conscript.cpp and .h...
you need to post the source code to the related files but judging from the errors you're redefining functions that you shouldn't be.
Nevermind, I got it figured out.
Hey, Could anyone send me links to "Roguelike" tutorials libraries etc? I have no clue where to start and can not find anything to read up on, If I am correct C++ (or java) should be a good language right?
You can write a roguelike in pretty much any language. You probably want a library like curses to handle terminal display.
[QUOTE=DestWa;35201065]Hey, Could anyone send me links to "Roguelike" tutorials libraries etc? I have no clue where to start and can not find anything to read up on, If I am correct C++ (or java) should be a good language right?[/QUOTE] [url]http://roguebasin.roguelikedevelopment.org/index.php/Articles[/url]
I need some help with properly doing beat detection with FMOD (3). I am using channel->getSpectrum with 8192 values for outputting different frequencies, but none of the tutorials I have found online seem to work properly. The problem is I understand the logic and maths behind the tutorials (average history compared to instant history, having a history buffer etc...) but whenever I implement it, it never seems to work properly. I require huge C (beat constant, can't really remember the actual term, but basically the value you multiply avg. energy with to compare with inst. energy) and not 1.4 or anything that is more commonly used. And when I do that I get multiple beats in a single beat (every time the energy drops more than a certain amount it registers as a beat) or completely missing beats when higher frequency sounds are higher compared to low frequency notes, even though there is a low frequency beat in the background. I also tried to use a second getSpectrum with lower number of values and even subdivide that array into different frequency bands to avoid missing beats, but I still haven't made any headway. Any pointers or help is very appreciated!
I've been trying to implement a lua->SFML binding, but I've been having some trouble.. The following code compiled [cpp] #include <lua.hpp> #include <SFML/Graphics.hpp> #define SCRIPT_FUNCTION( name ) static int name( lua_State *L ) namespace script { namespace render { } SCRIPT_FUNCTION( CreateWindow ) { sf::RenderWindow *window = new sf::RenderWindow( sf::VideoMode( 800,600 ), "title" ); lua_puslightuserdata(L, (void*)window ); } static const luaL_Reg render_functions[] = { { "CreateWindow", CreateWindow }, { NULL, NULL } }; void Bind( lua_State *L ) { luaL_setfuncs( L, render_functions, 0 ); lua_setglobal( L, "render" ); } } [/cpp] seems to cause some problems. Unfortunately, the problem is in the linking. [code] Undefined reference to 'sf::VideoMode::VideoMode( unsigned int, unsigned int )' Undefined reference to 'sf::RenderWindow::RenderWindow( sf::VideoMode, std::....' [/code] But I'm linking against the correct libraries, and there's no complaints from the compiler (gcc) nor the linker about not being able to find certain libraries.
[QUOTE=T3hGamerDK;35202753]I've been trying to implement a lua->SFML binding, but I've been having some trouble.. The following code compiled [cpp] #include <lua.hpp> #include <SFML/Graphics.hpp> #define SCRIPT_FUNCTION( name ) static int name( lua_State *L ) namespace script { namespace render { } SCRIPT_FUNCTION( CreateWindow ) { sf::RenderWindow *window = new sf::RenderWindow( sf::VideoMode( 800,600 ), "title" ); lua_puslightuserdata(L, (void*)window ); } static const luaL_Reg render_functions[] = { { "CreateWindow", CreateWindow }, { NULL, NULL } }; void Bind( lua_State *L ) { luaL_setfuncs( L, render_functions, 0 ); lua_setglobal( L, "render" ); } } [/cpp] seems to cause some problems. Unfortunately, the problem is in the linking. [code] Undefined reference to 'sf::VideoMode::VideoMode( unsigned int, unsigned int )' Undefined reference to 'sf::RenderWindow::RenderWindow( sf::VideoMode, std::....' [/code] But I'm linking against the correct libraries, and there's no complaints from the compiler (gcc) nor the linker about not being able to find certain libraries.[/QUOTE] Are you using static SFML libraries? If yes, then you have to compile your code with SFML_STATIC #defined.
[QUOTE=sim642;35202879]Are you using static SFML libraries? If yes, then you have to compile your code with SFML_STATIC #defined.[/QUOTE] Oooh, that explains it! Thanks a lot! [editline]19th March 2012[/editline] It still gives off the same errors. Do I have to #define it, or can I '-DSFML_STATIC' it?
[QUOTE=T3hGamerDK;35203068]Oooh, that explains it! Thanks a lot! [editline]19th March 2012[/editline] It still gives off the same errors. Do I have to #define it, or can I '-DSFML_STATIC' it?[/QUOTE] '-DSFML_STATIC' should do it since that basically does the same as #define.
[QUOTE=sim642;35203513]'-DSFML_STATIC' should do it since that basically does the same as #define.[/QUOTE] Yeah well, it doesn't work. I can post the premake generated Makefiles, if that would be needed? Or just the premake4.lua file?
Remember to use the -d libs when in debug mode.
[QUOTE=ief014;35204190]Remember to use the -d libs when in debug mode.[/QUOTE] I'm compiling SFML 2.0 myself using premake4 project files and not CMake, but thanks :)
Android AIDE's highlighting look like this: [t]http://imageshack.us/photo/my-images/838/aidehighlighting.jpg/[/t] [url]http://imageshack.us/photo/my-images/838/aidehighlighting.jpg/[/url] Anyone know how to disable it? Mainly because it makes scripting hard as hell.
[QUOTE=T3hGamerDK;35204322]I'm compiling SFML 2.0 myself using premake4 project files and not CMake, but thanks :)[/QUOTE] I find the premake script is buggy to say the least, i would just use cmake if I were you
[QUOTE=Richy19;35205225]I find the premake script is buggy to say the least, i would just use cmake if I were you[/QUOTE] I can't. I'm using premake in my project to build both my own project, and SFML 2.0, which is included in minimal format. I don't want to be using both CMake and Premake4. Also, this is no fault of premake, I'm sure.
What would be the easiest and cleanest way to change a directory that looks like this: [code]C:/Users/Username/AppData/Roaming[/code] Into this: [code]C:\\Users\\Username\\AppData\\Roaming[/code] in Lua?
[QUOTE=PieClock;35208286]What would be the easiest and cleanest way to change a directory that looks like this: [code]C:/Users/Username/AppData/Roaming[/code] Into this: [code]C:\\Users\\Username\\AppData\\Roaming[/code] in Lua?[/QUOTE] Using regex and string gsub?
lua patterns* and string gsub
[QUOTE=swift and shift;35159680]c# list stuff[/QUOTE] I know I'm kinda late on this one but have you guys ever heard of String.Join? It makes this kind of stuff really easy... [cpp]string stringedList = String.Join(" ", myList);[/cpp] (the first argument is the separator) Also, you might want to convert your list to an array first (no idea if this is required but still) [cpp]string stringedList = String.Join(" ", myList.ToArray());[/cpp]
-snip- Solved it myself, just forget to insert an extra parentheses.
What's a good way to set up file structure in Java? I can create packages just fine, which organizes all my class files, but I'd prefer to split source files into folders so I can look at them much more easily - I have a lot of files and I intend to add more.
[QUOTE=Ehmmett;35209557]If you find one, give me a shout. I've been dying to figure it out, but I can't come up with shit.[/QUOTE] I used to check with the old x position, and the new y position (after velocity application), then checking old y position and new x position and resolving the collision whichever way is shorter, however this bugs out if you try to test against a moving object.
Sorry, you need to Log In to post a reply to this thread.