1. Post #1
    Slaaf van EternalFlamez.Ik wilde heel graag de laatste Indie Bundle, en ik kreeg deze kuttitel er gratis bij.
    Staneh's Avatar
    March 2010
    4,073 Posts
    Post all the non-thread-worthy questions in this thread.

    V1
    V2
    V3
    V4

    Let's ask some questions!
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events

  2. Post #2
    miceiken's Avatar
    September 2008
    197 Posts
    Why does this say version 4? http://www.facepunch.com/threads/1152030
    Reply With Quote Edit / Delete Windows 7 Norway Show Events Programming King Programming King x 2 (list)

  3. Post #3
    Nigey Nige's Avatar
    June 2010
    1,341 Posts
    I need help finding WAYWO :(
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Funny Funny x 5Agree Agree x 1Programming King Programming King x 1 (list)

  4. Post #4
    Slaaf van EternalFlamez.Ik wilde heel graag de laatste Indie Bundle, en ik kreeg deze kuttitel er gratis bij.
    Staneh's Avatar
    March 2010
    4,073 Posts
    wow FUCK

    Edited:

    I need help finding WAYWO :(
    Waywo should be made really soon by Overv.
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events Informative Informative x 2Programming King Programming King x 1 (list)

  5. Post #5
    Icedshot's Avatar
    April 2010
    2,361 Posts
    Does anyone have any good resources/an opinion on CUDA vs DirectCompute vs OpenCL? I'm entirely lost as to where to begin/which one to pick

    Edit:

    Decided to go with OpenCL, due to working on several hardware brands not just nvidia, and also because it isn't reliant on directx, which i am trying to avoid
    Reply With Quote Edit / Delete Windows Vista United Kingdom Show Events Programming King Programming King x 1 (list)

  6. Post #6
    Gold Member
    vexx21322's Avatar
    December 2008
    10,661 Posts
    I ran into something that I can't quite understand, using regular expressions in javascript.
    I know this sounds like it should go in web development, but this isn't going towards the development of a webpage. (userscript)



    I want it to match both 1.1 and 1.1.+ but also have the brackets be a lazy match.

    Does anyone know the correct regular expression for this?
    Reply With Quote Edit / Delete Windows 7 United States Show Events Programming King Programming King x 1 (list)

  7. Post #7
    I am a moderator.
    Swebonny's Avatar
    August 2006
    13,248 Posts
    Likes this?

    \[1\.1(.1)*\]

    Edited:

    Basically checks if the value that comes after "[1.1" is (.1) and then check if it appears zero or more times then add bracket.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events Programming King Programming King x 1 (list)

  8. Post #8
    Gold Member
    Superbird's Avatar
    July 2007
    80 Posts
    Repost from last thread.

    Been messing around with GWEN as of lately but I can't seem to work this out.

    TestApp.cpp
    Code:
    #include "TestApp.h"
    
    
    GWEN_CONTROL_CONSTRUCTOR( TestApp )
    {
    	Dock( Pos::Fill );
    
    	CreateButton();
    
    }
    
    
    void TestApp::CreateButton()
    {
    	Controls::Button* pButtonA = new Controls::Button( this );
    	pButtonA->SetText( L"Start" );
    	pButtonA->onPress.Add( this, &TestApp::onButtonA );
    	pButtonA->SetPos(75, 175);
    }
    
    
    void TestApp::onButtonA()
    {
    	pButtonA->SetText("lol");	
    }
    TestApp.h
    Code:
    #pragma once
    
    #include "Gwen/Gwen.h"
    #include "Gwen/Controls.h"
    #include "Gwen/Controls/Layout/Position.h"
    #include "Gwen/Controls/WindowControl.h"
    
    using namespace Gwen;
    
    /*
    
    	The base panel
    
    */
    
    class TestApp : public Controls::Base 
    {
    	GWEN_CONTROL( TestApp, Controls::Base );
    
    public:
    		void onButtonA();
    		void CreateButton();
    
    };
    You can see in onButtonA() I am trying to set the text of pButtonA from CreateButton(), although I am getting "identifier pButtonA is undefned"
    Reply With Quote Edit / Delete Windows 7 Australia Show Events Programming King Programming King x 1 (list)

  9. Post #9
    Gold Member
    mechanarchy's Avatar
    September 2009
    1,214 Posts
    Repost from last thread.

    Been messing around with GWEN as of lately but I can't seem to work this out.
    void TestApp::CreateButton()
    {
    	Controls::Button* pButtonA = new Controls::Button( this );
    	pButtonA->SetText( L"Start" );
    	pButtonA->onPress.Add( this, &TestApp::onButtonA );
    	pButtonA->SetPos(75, 175);
    	
    	//
    	// pButtonA goes out of scope here and is no longer defined
    	//
    }
    

    so

    class TestApp : public Controls::Base 
    {
    	GWEN_CONTROL( TestApp, Controls::Base );
    
    public:
    		void onButtonA();
    		void CreateButton();
    		
    	//
    	// Add this here
    	//
    private:
    	Controls::Button* pButtonA;
    
    };
    

    then

    void TestApp::CreateButton()
    {
    	// change
    	// Controls::Button* pButtonA = new Controls::Button( this );
    	// to
    	pButtonA = new Controls::Button(this);
    	
    	// ...
    }
    
    Reply With Quote Edit / Delete Australia Show Events Friendly Friendly x 1Programming King Programming King x 1 (list)

  10. Post #10
    Gold Member
    Superbird's Avatar
    July 2007
    80 Posts
    Thanks!
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  11. Post #11
    Richy19's Avatar
    May 2010
    5,413 Posts
    Anyone know why Im getting this with linux when I try to run a SFML app?

    Code:
    ./SFMLTest: error while loading shared libraries: libsfml-graphics.so.2: cannot open shared object file: No such file or directory
    I have all the libraries:
    Code:
    richy@richy-Len:/usr/local/lib$ dir
    Box2D			    libcsfml-system.so	       libsfml-graphics.so.2
    libBox2D.a		    libcsfml-system.so.2       libsfml-graphics.so.2.0
    libBox2D.so		    libcsfml-system.so.2.0     libsfml-network-d.so
    libBox2D.so.2.1.0	    libcsfml-window-d.so       libsfml-network-d.so.2
    libcsfml-audio-d.so	    libcsfml-window-d.so.2     libsfml-network-d.so.2.0
    libcsfml-audio-d.so.2	    libcsfml-window-d.so.2.0   libsfml-network-s.a
    libcsfml-audio-d.so.2.0     libcsfml-window.so	       libsfml-network.so
    libcsfml-audio.so	    libcsfml-window.so.2       libsfml-network.so.2
    libcsfml-audio.so.2	    libcsfml-window.so.2.0     libsfml-network.so.2.0
    libcsfml-audio.so.2.0	    libsfgui-d.so	       libsfml-system-d.so
    libcsfml-graphics-d.so	    libsfgui-s.a	       libsfml-system-d.so.2
    libcsfml-graphics-d.so.2    libsfgui-s-d.a	       libsfml-system-d.so.2.0
    libcsfml-graphics-d.so.2.0  libsfgui.so		       libsfml-system-s.a
    libcsfml-graphics.so	    libsfml-audio-d.so	       libsfml-system.so
    libcsfml-graphics.so.2	    libsfml-audio-d.so.2       libsfml-system.so.2
    libcsfml-graphics.so.2.0    libsfml-audio-d.so.2.0     libsfml-system.so.2.0
    libcsfml-network-d.so	    libsfml-audio-s.a	       libsfml-window-d.so
    libcsfml-network-d.so.2     libsfml-audio.so	       libsfml-window-d.so.2
    libcsfml-network-d.so.2.0   libsfml-audio.so.2	       libsfml-window-d.so.2.0
    libcsfml-network.so	    libsfml-audio.so.2.0       libsfml-window-s.a
    libcsfml-network.so.2	    libsfml-graphics-d.so      libsfml-window.so
    libcsfml-network.so.2.0     libsfml-graphics-d.so.2    libsfml-window.so.2
    libcsfml-system-d.so	    libsfml-graphics-d.so.2.0  libsfml-window.so.2.0
    libcsfml-system-d.so.2	    libsfml-graphics-s.a       pkgconfig
    libcsfml-system-d.so.2.0    libsfml-graphics.so        python2.7
    Reply With Quote Edit / Delete Linux United Kingdom Show Events Programming King Programming King x 1 (list)

  12. Post #12
    Gold Member
    vexx21322's Avatar
    December 2008
    10,661 Posts
    Likes this?

    \[1\.1(.1)*\]

    Edited:

    Basically checks if the value that comes after "[1.1" is (.1) and then check if it appears zero or more times then add bracket.
    Should have been a little more clear. I don't care what comes after the 1.1, but this actually works fine for what I need right now. Thanks.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Programming King Programming King x 1 (list)

  13. Post #13
    Nigey Nige's Avatar
    June 2010
    1,341 Posts
    Odd bugs as I'm trying to get to grips with Love2d. Here's my main.lua:

    require "camera.lua"
    
    function love.load()
    	
    	love.graphics.setBackgroundColor(0, 0, 150)
    	love.graphics.setMode(800, 600, false, true, 0)
    	
    end
    
    function love.update(dt)
    	
    	if (love.keyboard.isDown("a")) then
    		camera.move(-1, 0)
    	end
    	
    	if (love.keyboard.isDown("d")) then
    		camera.move(1, 0)
    	end
    	
    	if (love.keyboard.isDown("s")) then
    		camera.move(0, 1)
    	end
    	
    	if (love.keyboard.isDown("w")) then
    		camera.move(0, -1)
    	end
    	
    	if (love.keyboard.isDown("e")) then
    		camera.rotate(1)
    	end
    	if (love.keyboard.isDown("q")) then
    		camera.rotate(-1)
    	end
    	
    end
    
    function love.draw()
    
    	camera:set()
    	--draw stuff
    	love.graphics.print("NIGEY NIGE", 300, 300)
    	camera:unset()
    
    end
    
    

    And here's my camera class:

    camera = {}
    camera.x = 0
    camera.y = 0
    camera.scaleX = 1
    camera.scaleY = 1
    camera.rotation = 0
    
    function camera:set()
    	love.graphics.push()
    	love.graphics.rotate(-camera.rotation)
    	love.graphics.scale(1 / camera.scaleX, 1 / camera.scaleY)
    	love.graphics.translate(-camera.x, -camera.y)
    end
    
    function camera:unset()
    	love.graphics.pop()
    end
    
    function camera:move(dx, dy)
    	camera.x = camera.x + (dx or 0)
    	camera.y = camera.y + (dy or 0)
    end
    
    function camera:rotate(dr)
    	camera.rotation = camera.rotation + dr
    end
    
    function camera:scale(sx, sy)
    	sx = sx or 1
    	camera.scaleX = camera.scaleX * sx
    	camera.scaleY = camera.scaleY * (sy or sx)
    end
    
    function camera:setPosition(x, y)
    	camera.x = x or camera.x
    	camera.y = y or camera.y
    end
    
    function camera:setScale(sx, sy)
    	camera.scaleX = sx or camera.scaleX
    	camera.scaleY = sy or camera.scaleY
    end

    The camera only moves when I press W or S, and then it moves sideways rather than up and down. I don't even know what the fuck
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Programming King Programming King x 1 (list)

  14. Post #14
    I am a moderator.
    Swebonny's Avatar
    August 2006
    13,248 Posts
    Should have been a little more clear. I don't care what comes after the 1.1, but this actually works fine for what I need right now. Thanks.
    Ah okay, then you can simply use \w (represents [a-zA-Z_0-9]).

    \[1\.1(.\w*)*\], it should now match with anything that starts with "[1.1" and ends with "]"
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  15. Post #15
    Hates php
    high's Avatar
    May 2006
    2,415 Posts
    Anyone know why Im getting this with linux when I try to run a SFML app?

    Code:
    ./SFMLTest: error while loading shared libraries: libsfml-graphics.so.2: cannot open shared object file: No such file or directory
    I have all the libraries:
    Code:
    richy@richy-Len:/usr/local/lib$ dir
    Box2D			    libcsfml-system.so	       libsfml-graphics.so.2
    libBox2D.a		    libcsfml-system.so.2       libsfml-graphics.so.2.0
    libBox2D.so		    libcsfml-system.so.2.0     libsfml-network-d.so
    libBox2D.so.2.1.0	    libcsfml-window-d.so       libsfml-network-d.so.2
    libcsfml-audio-d.so	    libcsfml-window-d.so.2     libsfml-network-d.so.2.0
    libcsfml-audio-d.so.2	    libcsfml-window-d.so.2.0   libsfml-network-s.a
    libcsfml-audio-d.so.2.0     libcsfml-window.so	       libsfml-network.so
    libcsfml-audio.so	    libcsfml-window.so.2       libsfml-network.so.2
    libcsfml-audio.so.2	    libcsfml-window.so.2.0     libsfml-network.so.2.0
    libcsfml-audio.so.2.0	    libsfgui-d.so	       libsfml-system-d.so
    libcsfml-graphics-d.so	    libsfgui-s.a	       libsfml-system-d.so.2
    libcsfml-graphics-d.so.2    libsfgui-s-d.a	       libsfml-system-d.so.2.0
    libcsfml-graphics-d.so.2.0  libsfgui.so		       libsfml-system-s.a
    libcsfml-graphics.so	    libsfml-audio-d.so	       libsfml-system.so
    libcsfml-graphics.so.2	    libsfml-audio-d.so.2       libsfml-system.so.2
    libcsfml-graphics.so.2.0    libsfml-audio-d.so.2.0     libsfml-system.so.2.0
    libcsfml-network-d.so	    libsfml-audio-s.a	       libsfml-window-d.so
    libcsfml-network-d.so.2     libsfml-audio.so	       libsfml-window-d.so.2
    libcsfml-network-d.so.2.0   libsfml-audio.so.2	       libsfml-window-d.so.2.0
    libcsfml-network.so	    libsfml-audio.so.2.0       libsfml-window-s.a
    libcsfml-network.so.2	    libsfml-graphics-d.so      libsfml-window.so
    libcsfml-network.so.2.0     libsfml-graphics-d.so.2    libsfml-window.so.2
    libcsfml-system-d.so	    libsfml-graphics-d.so.2.0  libsfml-window.so.2.0
    libcsfml-system-d.so.2	    libsfml-graphics-s.a       pkgconfig
    libcsfml-system-d.so.2.0    libsfml-graphics.so        python2.7
    Is /usr/local/lib in your $PATH? That is my only guess as to whats wrong.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  16. Post #16
    Richy19's Avatar
    May 2010
    5,413 Posts
    Is /usr/local/lib in your $PATH? That is my only guess as to whats wrong.
    Doint a sudo ldconfig fixed it :P
    Reply With Quote Edit / Delete Linux United Kingdom Show Events

  17. Post #17
    I gave ••••• enough money to buy a soda.
    Funley's Avatar
    May 2010
    1,426 Posts
    In XNA, i have a tilemap. Every tile in it is stored in a list. I need to store the sandpath in a separate list but still have it in the normal tile list. The path pieces have to be ordered in the list so that the first piece in the list is the one next to the green blob (start), the rest ordered on how the path goes and the last is next to the gray square (end). I have no idea how to do this. I added some numbers to the image to simply show how i want the ordered.

    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  18. Post #18
    Richy19's Avatar
    May 2010
    5,413 Posts
    With C# is it possible to pass a function as a parameter?
    I wanst to make a button class, but I want to pass it a function to call if its clicked on.
    Reply With Quote Edit / Delete Linux United Kingdom Show Events

  19. Post #19
    Gold Member
    vexx21322's Avatar
    December 2008
    10,661 Posts
    Ah okay, then you can simply use \w (represents [a-zA-Z_0-9]).

    \[1\.1(.\w*)*\], it should now match with anything that starts with "[1.1" and ends with "]"
    Had to slightly modify it, but that worked much better. Thanks.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  20. Post #20
    affail's Avatar
    January 2012
    23 Posts
    In Java/Android how can I use one class file with all my menu code over all of my views?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  21. Post #21
    Simspelaaja's Avatar
    June 2008
    486 Posts
    With C# is it possible to pass a function as a parameter?
    I wanst to make a button class, but I want to pass it a function to call if its clicked on.
    Code:
    public delegate void DoStuffDelegate();
    
    public class Button
    {
    	private DoStuffDelegate _function;
    	
    	public Button(DoStuffDelegate function)
    	{
    		_function = function;
    	}
    	
    	public OnPress()
    	{
    		_function();
    	}
    }
    Untested.
    Reply With Quote Edit / Delete Windows Vista Finland Show Events

  22. Post #22
    Eudoxia's Avatar
    July 2009
    6,009 Posts
    Suppose you have an interpreter that needs to look up the name of the function you're calling to decide what to do, which would be faster?

    Code:
    enum function_codes {core_this, core_that,...}
    
    map<string,function_codes> language_core;
    
    string function = //Draw from input
    if(language_core.find(function) != language_core.end())
    {
       function_codes code = it->second;
       switch(code)
       {
          case core_this:
             return core_This(argNumber,input);
             break;
          ...
       }
    }
    Code:
    string function = //Draw from input
    if(function == "this")
      return core_This(argNumber,input);
    else if(function == "that")
      ...
    else
    {
      cerr << "Unknown function.";
      Unwind();
    }
    Reply With Quote Edit / Delete Linux Uruguay Show Events Funny Funny x 1 (list)

  23. Post #23
    Gold Member
    PortalGod's Avatar
    August 2009
    2,382 Posts
    First of all, here's a picture of my project:



    the panel with the border on the right is named "Tiles". That PictureBox you see is named "tile1", and is the only thing inside the Tiles panel. In my code, I have this:

    Code:
    For chkTile = 1 To Count
        Dim oldTile As PictureBox = Tiles.Controls.Item("tile" & chkTile)
        pbOrig.Image = oldTile.Image
        pbNew.Image = Tile
        isOld = CompareTiles(oldTile.Image, Tile)
    Next
    where Count is the number of elements in the "Tiles" panel (1), pbOrig is the small picturebox you see on the right at the bottom, and pbNew is the one on the left. pbOrig's image should be the same as the one is the "Tiles" panel, but it's the same as the "Tile" variable. Can anyone help?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  24. Post #24
    Gold Member
    ZenX2's Avatar
    February 2009
    5,128 Posts
    Odd bugs as I'm trying to get to grips with Love2d. Here's my main.lua:

    -snop-

    And here's my camera class:

    -snop-

    The camera only moves when I press W or S, and then it moves sideways rather than up and down. I don't even know what the fuck
    You're using : when defining it. This is for methods, and it's a bit a syntactic sugar.

    Basically, now, when you define camera:move(dx, dy), lua interprets this as camera.move(self, dx, dy). "self" is the table calling the function if you use table:method()

    Because of this, when you are calling camera.move(1, 0) or a variation of that, you're passing 1 as self, and 0 as dx.


    Also, I just realized that I made v2 over a year ago. I hadn't realized that I've been chilling with you guys for that long.

    Reply With Quote Edit / Delete Windows 7 United States Show Events Friendly Friendly x 1Informative Informative x 1 (list)

  25. Post #25
    Em See's Avatar
    January 2008
    1,116 Posts
    Just a quick one, I'm getting started with Java programming (uni related, but I'm not complaining), using sublime for writing it and a command prompt (or terminal, depending on which computer I'm using) to compile and run it.

    Now I made a quick first project which takes say "30C" and interprets it as 30 degrees to be converted from Celsius to Fahrenheit - this works perfectly, and I even found out I could make it use Swing prompts and messages instead of relying on standard outputs and inputs with the terminal.

    .. But I can't run the .class outside of a terminal. It only functions if I run it via "java DegreesConversion" in a terminal, at which point the prompts appear and it functions as intended (without any communication to or from the terminal). When I launch the .class outside of the terminal (i.e. running it with the JRE in Ubuntu or in Windows), the loading cursor appears for half a second and disappears.

    I'm not sure if this is because I'm just using a single .class? Has it got something to do with dependencies? I come from a .NET background so uh, I'm a bit stuck here.
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  26. Post #26
    I am a moderator.
    Swebonny's Avatar
    August 2006
    13,248 Posts
    Suppose you have an interpreter that needs to look up the name of the function you're calling to decide what to do, which would be faster?

    Code:
    enum function_codes {core_this, core_that,...}
    
    map<string,function_codes> language_core;
    
    string function = //Draw from input
    if(language_core.find(function) != language_core.end())
    {
       function_codes code = it->second;
       switch(code)
       {
          case core_this:
             return core_This(argNumber,input);
             break;
          ...
       }
    }
    Code:
    string function = //Draw from input
    if(function == "this")
      return core_This(argNumber,input);
    else if(function == "that")
      ...
    else
    {
      cerr << "Unknown function.";
      Unwind();
    }
    I checked the map reference, and it stated that the ".find" executes in logarithmic time, while your second code seems to do things in constant time.
    So the last one should be faster.

    http://www.facepunch.com/threads/116...1#post34974180
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  27. Post #27
    Facepunch's #1 Huskybutt
    James xX's Avatar
    July 2011
    2,095 Posts
    I'm having a couple problems with a program I am making. I tried to get Lua in my project , except I get a link error each time and I have no clue why. I'm also trying to make an event system ( like the hook library in Garry's mod ) except I don't know how to store a function in an array ( and call it ). I would be extremely grateful if someone could help me out here. ( Ps : It's in c++ )
    Reply With Quote Edit / Delete Windows XP France Show Events

  28. Post #28
    Wyzard's Avatar
    June 2008
    1,243 Posts
    I checked the map reference, and it stated that the ".find" executes in logarithmic time, while your second code seems to do things in constant time.
    An if/else stack runs in linear time; the number of conditions that have to be tested varies linearly with the total number of conditions. (On average, it'll be about half of them.)

    The map lookup is faster, but the switch(code) that follows it runs in linear time, which negates the benefit. It'd be better to have the object in the map contain a pointer to the function, or be a callable object itself, so that you don't have to do that second lookup after finding the map entry.
    Reply With Quote Edit / Delete Linux United States Show Events Informative Informative x 2 (list)

  29. Post #29
    Nigey Nige's Avatar
    June 2010
    1,341 Posts
    You're using : when defining it. This is for methods, and it's a bit a syntactic sugar.

    Basically, now, when you define camera:move(dx, dy), lua interprets this as camera.move(self, dx, dy). "self" is the table calling the function if you use table:method()

    Because of this, when you are calling camera.move(1, 0) or a variation of that, you're passing 1 as self, and 0 as dx.


    Also, I just realized that I made v2 over a year ago. I hadn't realized that I've been chilling with you guys for that long.

    Thanks man! I guess that's what I get for blindly following obscure tutorials.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  30. Post #30
    I am a moderator.
    Swebonny's Avatar
    August 2006
    13,248 Posts
    An if/else stack runs in linear time; the number of conditions that have to be tested varies linearly with the total number of conditions. (On average, it'll be about half of them.)

    The map lookup is faster, but the switch(code) that follows it runs in linear time, which negates the benefit. It'd be better to have the object in the map contain a pointer to the function, or be a callable object itself, so that you don't have to do that second lookup after finding the map entry.
    Ah yes, that's true. Forgot about that.

    Directing my earlier post to yours.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  31. Post #31
    itty-bitty pretty kitty
    Dennab
    September 2008
    9,837 Posts
    How do I disable font smoothing in LÖVE?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  32. Post #32
    Facepunch's #1 Huskybutt
    James xX's Avatar
    July 2011
    2,095 Posts
    I'm making my events.cpp file now, but I get linker errors when I use it.

    events.cpp
    // Events.cpp
    
    #ifndef _EVENTS
    #define _EVENTS
    
    class Hook{
    	public:
    		void Func( );
    		Hook( ){  };
    };
    
    class Event{
    
    	private:
    
    		Hook* HookedEvents[255];
    		int AMT;
    
    	public:
    
    		Event( ){ AMT = 0; }
    		~Event( ){ }
    
    		void AddHook( Hook* MyHook ){
    			AMT = AMT + 1;
    			HookedEvents[ AMT ] = MyHook;
    		}
    
    		void Call( ){
    			int a = 1;
    			for ( a = 1; a <= AMT; a++){
    				Hook* CurrentHook = HookedEvents[ a ];
    				CurrentHook->Func();
    			}
    		}
    };
    
    #endif
    

    Use:

    // ...
    Event* OnDraw = new Event;
    
    // ... in a function
    OnDraw->Call();
    
    // ... 
    class MyDrawHook : public Hook
    {
    	public:
    		void Func(){ cout << "win"; }
    };
    
    // In a function:
    
    MyDrawHook* MyDrawHook2 = new MyDrawHook;
    OnDraw->AddHook( reinterpret_cast<Hook*>(MyDrawHook2) );
    
    

    any ideas?

    Code:
    1>Main.obj : error LNK2001: unresolved external symbol "public: void __thiscall Hook::Func(void)" (?Func@Hook@@QAEXXZ)
    Reply With Quote Edit / Delete Windows XP France Show Events

  33. Post #33
    Gold Member
    BlkDucky's Avatar
    May 2008
    6,503 Posts
    How do I disable font smoothing in LÖVE?
    You should be able to draw the text to a buffer and then nearest neighbour scale it up or down as required.

    I don't think you can disable it otherwise unless you use a bitmap font.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Agree Agree x 1 (list)

  34. Post #34
    Eudoxia's Avatar
    July 2009
    6,009 Posts
    I checked the map reference, and it stated that the ".find" executes in logarithmic time, while your second code seems to do things in constant time.
    So the last one should be faster.

    http://www.facepunch.com/threads/116...1#post34974180
    I went ahead and checked it, turns out direct "if else" takes twice as long. Then I saw the update to your post. I thought switch statements were all optimized and fast and shit, but it makes a lot of sense to keep the function in the map, and just doing something like "return it->second". Thanks dudebros.
    Reply With Quote Edit / Delete Linux Uruguay Show Events

  35. Post #35
    I am a moderator.
    Swebonny's Avatar
    August 2006
    13,248 Posts
    I went ahead and checked it, turns out direct "if else" takes twice as long. Then I saw the update to your post. I thought switch statements were all optimized and fast and shit, but it makes a lot of sense to keep the function in the map, and just doing something like "return it->second". Thanks dudebros.
    Thank Wyzard
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  36. Post #36

    May 2011
    213 Posts
    I wrote a simple C function to uppercase a string without altering the original. It works fine, except there's a weird bug that causes the 9th character to always change to the next letter in the alphabet (so r changes to s and a to b, etc.)

    char* strtoupper(char* str)
    {
    	char* strup = "";
    	int i;
    	size_t i_max = sizeof(str) * sizeof(char*);
    
    	for (i = 0; i < i_max; i++)
    	{
    		strup[i] = toupper(str[i]);
    	}
    
    	return strup;
    }

    printf("%s", strtoupper("Character Stats")); // outputs 'CHARACTES STATS'

    Any ideas on what's causing this?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  37. Post #37
    *cough*
    Willox's Avatar
    December 2009
    1,391 Posts
    I've recently been working on a sort of "Game Engine" in XNA and I've got entities down etc, but I'm not sure on how to store/load/display maps, I've been trying all day and all the examples like to use height maps which I have come to hate.

    My question is basically what method should I look in to other than height maps for maps in an XNA project.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  38. Post #38
    evil-tedoz's Avatar
    October 2007
    129 Posts
    I wrote a simple C function to uppercase a string without altering the original. It works fine, except there's a weird bug that causes the 9th character to always change to the next letter in the alphabet (so r changes to s and a to b, etc.)

    char* strtoupper(char* str)
    {
    	char* strup = "";
    	int i;
    	size_t i_max = sizeof(str) * sizeof(char*);
    
    	for (i = 0; i < i_max; i++)
    	{
    		strup[i] = toupper(str[i]);
    	}
    
    	return strup;
    }

    printf("%s", strtoupper("Character Stats")); // outputs 'CHARACTES STATS'

    Any ideas on what's causing this?
    Maybe you could try using strlen to get the size of your string.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  39. Post #39

    May 2011
    213 Posts
    Maybe you could try using strlen to get the size of your string.
    That works, but the output doesn't change
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  40. Post #40
    Hates php
    high's Avatar
    May 2006
    2,415 Posts
    I wrote a simple C function to uppercase a string without altering the original. It works fine, except there's a weird bug that causes the 9th character to always change to the next letter in the alphabet (so r changes to s and a to b, etc.)

    char* strtoupper(char* str)
    {
    	char* strup = "";
    	int i;
    	size_t i_max = sizeof(str) * sizeof(char*);
    
    	for (i = 0; i < i_max; i++)
    	{
    		strup[i] = toupper(str[i]);
    	}
    
    	return strup;
    }

    printf("%s", strtoupper("Character Stats")); // outputs 'CHARACTES STATS'

    Any ideas on what's causing this?
    You never allocate memory for strup. So you are probably getting some undefined behavior from writing to 'unallocated' memory.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 2 (list)