1. Post #2881
    Gold Member
    Naelstrom's Avatar
    June 2010
    2,753 Posts
    I have kind of found myself at a roadblock. I have being learning Lua for a while now, and feel like I have a firm grasp on how it works and how I can use it with Love2D, however I don't know how to advance from here... I know how to use the various APIs for Love2D and such but don't know how to take the next step :| Any suggestions?
    Is Love2D unsatisfactory for you? What do you desire? If you want to have more power over what's going on you can try C or C++. If you want to do more faster (with a similar power increase) try C#.
    Reply With Quote Edit / Delete Linux United States Show Events

  2. Post #2882
    Gold Member
    confinedUser's Avatar
    October 2008
    3,639 Posts
    ok so i redid the whole random number roll to hit your opponent and opponent to hit you here is what i get. However it needs to be over 20 to hit. Heres the code. i only posted this because this one has me scratching my head, i fixed most of the errors myself.

    Code:
    #include <iostream>
    #include <cstdlib>
    #include <ctime>
    #include <string>
    
    using namespace std;
    
    int main()
    {
        string name;
        string prompt = "Welcome to war of the gangs what is your name?: ";
        cout << prompt;
        getline(cin, name);
        cout <<"ok " << name << "prepare for battle!";
        int turn = 1;
        int damage = 5;
        int playerhealth = 100;
        int enemyhealth = 100;
        srand(time(NULL));
     int roll;
        while(playerhealth == 100 && enemyhealth == 100)
        {
         roll = rand() % 31;
    
        if(roll <= 20)
        {
            cout << "\nthe shots missed! " << roll;
        }
        else if(roll >= 20)
        {
            roll = rand() % 31;
            cout << " \nRival was hit!" << roll;
            enemyhealth = enemyhealth - damage;
            cout << " Rivals health: " << enemyhealth;
            turn = 2;
        }
        if(turn == 2 && roll < 20)
        {
            roll = rand() % 31;
            cout << "\nRivals shots missed! " << roll;
            turn = 1;
        }
        else if(turn == 2 && roll >= 20)
        {
            roll = rand() % 31;
            cout << "\nRival hit you!" << roll;
            playerhealth = playerhealth - damage;
            cout << "\nYour health remaining: " << playerhealth;
        }
                if(playerhealth == 0)
                {
            cout << "you failed your fellow gang memebers respect.";
                }
            else if(enemyhealth == 0)
            {
            cout << "you have been promoted to high class member.";
            }
        }
        return 0;
    }
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  3. Post #2883
    Gold Member
    WTF Nuke's Avatar
    March 2009
    4,469 Posts
    Whats a way to read a file quickly in Java? I just have a simple text file, and I want to read the map information from there, however using a scanner seems to take a hell of a long time when the map is big enough (right now it's 60*30). Is there a way to make it read faster, or to use an unstructured reader and just ignore newlines and spaces?

    Edited:

    Also, for some reason my app takes a long time to compose the screen, according to the show CPU debugger option (Android). This causes the device to heat up, but the thing is pretty simple right now. It does the same thing with my friend's phone, but we both get steady ~66 fps. It does have to render ~4000 triangles on my phone, but the data is all the same (they all make up squares). If this is it, how can I optimize drawing so many triangles?
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  4. Post #2884
    AlienCat's Avatar
    October 2011
    508 Posts
    ok so i redid the whole random number roll to hit your opponent and opponent to hit you here is what i get. However it needs to be over 20 to hit. Heres the code. i only posted this because this one has me scratching my head, i fixed most of the errors myself.
    Code:
    while(playerhealth == 100 && enemyhealth == 100)
    Dunno really what the problem is, but if you use this condition, the program will quit if anyone get hit once.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  5. Post #2885
    Gold Member
    confinedUser's Avatar
    October 2008
    3,639 Posts
    Dunno really what the problem is, but if you use this condition, the program will quit if anyone get hit once.
    i was going to solve that one but thanks for spotting it, look at the last line it said 14 was a hit when it should of been a miss
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  6. Post #2886
    Taught by John Lua
    MakeR's Avatar
    May 2007
    2,914 Posts
    You are re-rolling after checking if the enemy roll is above 20:

    Code:
    else if(turn == 2 && roll >= 20)
    {
        roll = rand() % 31;
        cout << "\nRival hit you!" << roll;
        playerhealth = playerhealth - damage;
        cout << "\nYour health remaining: " << playerhealth;
    }
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Informative Informative x 1 (list)

  7. Post #2887
    I gave enough money to buy a soda.
    Funley's Avatar
    May 2010
    1,424 Posts
    In C#, how can i parse this string "0:5:1000" into an array which will look like {0, 5, 1000}. Note that the array has to have ints. Thanks :)
    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  8. Post #2888
    NovembrDobby's Avatar
    April 2007
    1,157 Posts
    Code:
    using System.Collections.Generic;
    using System.Linq;
    
    string nums = "0:5:1000"
    List<string> strs = nums.Split(':');
    List<int> result = new List<int>();
    strs.ForEach(item => result.Add(Convert.ToInt16(item)));
    something like that, I can't test it right now
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  9. Post #2889
    Gold Member
    confinedUser's Avatar
    October 2008
    3,639 Posts
    You are re-rolling after checking if the enemy roll is above 20:

    Code:
    else if(turn == 2 && roll >= 20)
    {
        roll = rand() % 31;
        cout << "\nRival hit you!" << roll;
        playerhealth = playerhealth - damage;
        cout << "\nYour health remaining: " << playerhealth;
    }
    oh so that's whats been getting me. Thanks :)
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  10. Post #2890
    Gold Member
    JakeAM's Avatar
    March 2011
    1,574 Posts
    Is Love2D unsatisfactory for you? What do you desire? If you want to have more power over what's going on you can try C or C++. If you want to do more faster (with a similar power increase) try C#.
    It's not really unsatisfactory, it's more that I know Lua and how to use Love2D but don't know how to move on to actually make decent things from this.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Informative Informative x 1 (list)

  11. Post #2891
    pryrotechfan's Avatar
    August 2006
    20 Posts
    Does anyone have a good resource for implementing quadtrees or octrees? I understand the concept, but I just don't know what goes into the actual structure.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  12. Post #2892
    Richy19's Avatar
    May 2010
    5,406 Posts
    Does anyone have a good resource for implementing quadtrees or octrees? I understand the concept, but I just don't know what goes into the actual structure.
    http://en.wikipedia.org/wiki/Quadtree
    http://www.codeproject.com/Articles/...mentation-in-C
    http://www.kyleschouviller.com/wsuxn...urce-included/
    http://blog.notdot.net/2009/11/Damn-...Hilbert-Curves
    http://www.gamedev.net/page/resource...uadtrees-r1303

    As for octtrees I havent really looked yet, but its pretty much the same as quadtree, but with a nother dimension
    Reply With Quote Edit / Delete Linux United Kingdom Show Events

  13. Post #2893
    pryrotechfan's Avatar
    August 2006
    20 Posts
    Thanks for all the resources. I should be able to get it after this....hopefully.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  14. Post #2894
    calzoneman's Avatar
    February 2008
    460 Posts
    Whats a way to read a file quickly in Java? I just have a simple text file, and I want to read the map information from there, however using a scanner seems to take a hell of a long time when the map is big enough (right now it's 60*30). Is there a way to make it read faster, or to use an unstructured reader and just ignore newlines and spaces?

    Edited:

    Also, for some reason my app takes a long time to compose the screen, according to the show CPU debugger option (Android). This causes the device to heat up, but the thing is pretty simple right now. It does the same thing with my friend's phone, but we both get steady ~66 fps. It does have to render ~4000 triangles on my phone, but the data is all the same (they all make up squares). If this is it, how can I optimize drawing so many triangles?
    Can you explain more about the file format and how it is being translated into memory? The fastest way to read data depends on the source and destination format of the data.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  15. Post #2895
    Richy19's Avatar
    May 2010
    5,406 Posts
    Why the hell am I getting this:


    obj/Debug/src/Shader.o||In function `PrintGLErrors()':|
    /home/richy/codeblocks/GLUtil/src/./Utilities.hpp|7|multiple definition of `PrintGLErrors()'|
    obj/Debug/src/FBO.o:/home/richy/codeblocks/GLUtil/src/./Utilities.hpp|7|first defined here|

    I have
    
    #ifndef UTILITIES_HPP_INCLUDED
    #define UTILITIES_HPP_INCLUDED
    
    #include "./GLUtilMaster.hpp"
    
    bool PrintGLErrors()
    {
        GLuint ec = glGetError ();
        if (ec != 0) {
                std::cout << ec << std::endl;
                return false;
        }
        return true;
    }
    
    #endif // UTILITIES_HPP_INCLUDED
    

    Then GLUtilMaster.hpp includes the utilities.hpp, and all classes include GLUtilMaster.hpp, I thought the ifndef... was meant to prevent this
    Reply With Quote Edit / Delete Linux United Kingdom Show Events

  16. Post #2896
    Gold Member
    WTF Nuke's Avatar
    March 2009
    4,469 Posts
    Can you explain more about the file format and how it is being translated into memory? The fastest way to read data depends on the source and destination format of the data.
    It's a TXT file encoded with ANSI, however I can change this at any time. The destination is to be used in an ArrayList, as this is a map. I'm not sure about the encoding though, as I am just using the Eclipse editor to save it to the android app.

    Edited:

    So I am trying to speed up my drawing, and this is my current draw function.
    {	
    	GLES20.glUniformMatrix3fv(mTextureMatrixHandle, 1, false, render.mTexMatrix, 0);
        Matrix.setIdentityM(mModelMatrix, 0);
    	Matrix.translateM(mModelMatrix, 0, render.mPos.X, render.mPos.Y, 0);
        Matrix.scaleM(mModelMatrix, 0, render.mWidth, render.mHeight, 1.f);
        if(camera){
        	Matrix.multiplyMM(mMVPMatrix, 0, mCameraMatrix, 0, mModelMatrix, 0);
        	Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);
        }
        else
        	Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mModelMatrix, 0);
        
        GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);
        GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 6);
    
    }

    According to DDMS tracer, this uses up 92% of CPU time. The distribution is self, 37.4%, multiplyMM 17.8%, drawArrays, 11%, and the other functions take about 7%-5% each. What confuses me is that the function itself takes up 37.4% of the CPU time, yet it does nothing but call other functions, apart from a boolean check. Is this normal? And how can I optimize this?
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  17. Post #2897
    jung3o's Avatar
    October 2011
    2,162 Posts
    I think I've seen somewhere in this sub forum that they don't like python. I would be nice if why python is bad because I just started learning it and if i should stop and learn something else.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  18. Post #2898
    calzoneman's Avatar
    February 2008
    460 Posts
    I think I've seen somewhere in this sub forum that they don't like python. I would be nice if why python is bad because I just started learning it and if i should stop and learn something else.
    Python is a great language for learning. I think there are 2 main reasons Facepunchers don't like it:
    1. The syntax is very different from C-like languages (this is just a personal preference)
    2. Some people have a superiority complex for languages that get faster scores on arbitrary benchmarks

    As long as the tutorials you're learning from (if you are using tutorials) are teaching the right practices the language is really irrelevant.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  19. Post #2899
    AlienCat's Avatar
    October 2011
    508 Posts
    There are some easy way to swap between a native pc application and an android one in java or do you need to keep two different projects?
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  20. Post #2900
    Gold Member
    WTF Nuke's Avatar
    March 2009
    4,469 Posts
    There are some easy way to swap between a native pc application and an android one in java or do you need to keep two different projects?
    Depends on what you're doing.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  21. Post #2901
    Doom's Avatar
    August 2011
    591 Posts
    I'm kind of new to C#, and programming at all. I'm trying to create a fairly simple program in which a you're presented with a conversation and have three replies. Each reply award you with a number of affection points. Obviously just something I'm creating as a learning progress. Anyway, I have a button which is supposed to check what you've chosen. You choose by checking a radiobutton, and the way I wanted it to work was using switch statements.

    As far as I know, you can't check several different radiobuttons within a switch statement, so I created several switch statements within the button curly braces, and I'm getting errors. Here's the code

    Code:
    private void button1_Click(object sender, EventArgs e)
            {
                switch (radioButtona.Checked)
                {
                    case true:
                        MessageBox.Show("You gained 1 affection point!");
                        break;
                    default:
                        break;
                }
                switch (radioButtonb.Checked)
                    case true:
                        MessageBox.Show("You gained 0 affection points!");
                        break;
                    default:
                        break;
                }
                switch (radioButtonc.Checked)
                {
                    case true:
                        MessageBox.Show("You gained 2 affection points!");
                        break;
                    default:
                        break;
                }
    Can someone tell me how to fix this, or tell me about a better way to execute this? Thanks :)

    Edited:

    Oh by the way, if someone would love to have a noob in his friend list, on Steam, asking questions like this once in a while, feel free to add me ^^
    Reply With Quote Edit / Delete Windows 7 Denmark Show Events

  22. Post #2902
    Gold Member
    robmaister12's Avatar
    January 2008
    4,969 Posts
    There's no point to switching on a bool, switch is meant for cases where there are a lot of different possible values (for example, with enums) and you don't want to create a giant if-else if block. You can turn each switch block into:

    if (radioButtona.Checked)
        MessageBox.Show("You gained 1 affection point!");
    else if (radioButtonb.Checked)
        MessageBox.Show("You gained 0 affection points!");
    else if (radioButtonc.Checked)
        MessageBox.Show("You gained 2 affection points!");
    

    Also it would help us a LOT if you could post the actual error you get instead of just saying you're getting an error. From just what I see here, you're missing an opening bracket on the second switch block and the closing bracket at the very end.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  23. Post #2903
    Doom's Avatar
    August 2011
    591 Posts
    There's no point to switching on a bool, switch is meant for cases where there are a lot of different possible values (for example, with enums) and you don't want to create a giant if-else if block. You can turn each switch block into:

    if (radioButtona.Checked)
        MessageBox.Show("You gained 1 affection point!");
    else if (radioButtonb.Checked)
        MessageBox.Show("You gained 0 affection points!");
    else if (radioButtonc.Checked)
        MessageBox.Show("You gained 2 affection points!");
    

    Also it would help us a LOT if you could post the actual error you get instead of just saying you're getting an error. From just what I see here, you're missing an opening bracket on the second switch block and the closing bracket at the very end.
    Ah thanks a lot :)

    The reason why I didn't do that is because I get 11, to be quite specific. My guess was that you simply couldn't have several switch statements ^^
    Reply With Quote Edit / Delete Windows 7 Denmark Show Events

  24. Post #2904
    Gold Member
    robmaister12's Avatar
    January 2008
    4,969 Posts
    Ah thanks a lot :)

    The reason why I didn't do that is because I get 11, to be quite specific. My guess was that you simply couldn't have several switch statements ^^
    Not in a way that would be simple. You could reduce duplicated code by having the if statements set a value that you format into the string, something like this:

    int points = 0;
    if (radioButtona.Checked)
        points += 1;
    //...
    
    MessageBox.Show(string.Format("You gained {0} affection points!", points));
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  25. Post #2905
    Gold Member
    Parakon's Avatar
    November 2008
    8,520 Posts
    going to attempt to learn c++ what do I need a compiler text editor and debugger? i haven't the faintest
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  26. Post #2906
    dajoh's Avatar
    March 2011
    625 Posts
    Get Visual Studio 2010.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events Agree Agree x 5Disagree Disagree x 2 (list)

  27. Post #2907
    Gold Member
    Parakon's Avatar
    November 2008
    8,520 Posts
    thanks
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  28. Post #2908
    Andrew McWatters
    Dennab
    March 2011
    4,658 Posts
    Do all of these gl helper libraries and multimedia frameworks have a delay when opening a window? It's the most annoying think to me to see SDL_app or GLFW Window and a white screen for a second before the title of the application window actually gets changed. Why does this occur? Does anyone here have experience with getting rid of this issue?
    Reply With Quote Edit / Delete Windows 7 United States Show Events Friendly Friendly x 1 (list)

  29. Post #2909
    Gold Member
    confinedUser's Avatar
    October 2008
    3,639 Posts
    going to attempt to learn c++ what do I need a compiler text editor and debugger? i haven't the faintest
    you could use code::blocks
    Reply With Quote Edit / Delete Windows 7 United States Show Events Disagree Disagree x 1 (list)

  30. Post #2910
    Taught by John Lua
    MakeR's Avatar
    May 2007
    2,914 Posts
    Do all of these gl helper libraries and multimedia frameworks have a delay when opening a window? It's the most annoying think to me to see SDL_app or GLFW Window and a white screen for a second before the title of the application window actually gets changed. Why does this occur? Does anyone here have experience with getting rid of this issue?
    I only get this issue when running with a debugger attached.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Agree Agree x 1 (list)

  31. Post #2911
    Chezburger's Avatar
    February 2009
    727 Posts
    Hi,

    I have a little problem doing some math in C++
    The problem is simple, but it has kept me going for a few days now.

    Basically, I am trying to calculate this: 2^t, where the user of the program fills in a value of t, however it just keeps giving me 1 as answer.

    How the code is build up:
    int t;
    long double d = pow(2, t);

    cin >> t >> endl;
    cout << d << endl;
    (With all the other, proper working things stripped from it, of course.)

    Anyone that could help me out on this one?
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events

  32. Post #2912

    January 2012
    421 Posts
    cin should be before long double.... and after int t;

    Otherwise t is unitialized, also, I dont think you should have endl; in cin, but I could be wrong.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events Agree Agree x 1Informative Informative x 1 (list)

  33. Post #2913
    Taught by John Lua
    MakeR's Avatar
    May 2007
    2,914 Posts
    You are powering t before you get it from standard input.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Informative Informative x 1 (list)

  34. Post #2914
    Chezburger's Avatar
    February 2009
    727 Posts
    Ah yes! It works properly now! Thanks a lot!
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events

  35. Post #2915
    ArgvCompany's Avatar
    June 2012
    549 Posts
    I think I've seen somewhere in this sub forum that they don't like python. I would be nice if why python is bad because I just started learning it and if i should stop and learn something else.
    Many Facepunchers seem biased towards low-level imperative languages. Python is a bit higher level than C++ and that stuff.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  36. Post #2916
    ECrownofFire's Avatar
    January 2011
    2,031 Posts
    Is there any reason why glGetBufferParameteriv would segfault only on the second time it runs? It goes fine the first time, but then it just segfaults on the second call to it.

    Also, running it through GDB doesn't cause a segfault. What the fuck is happening? It just suddenly stopped working.
    Reply With Quote Edit / Delete Windows XP United States Show Events

  37. Post #2917
    AlienCat's Avatar
    October 2011
    508 Posts
    Depends on what you're doing.
    Sorry I am being dumb, basically it is an OpenGL program and most of the things (assuming that OpenGL ES can run on a computer) functions in the same way. The notable differences are input and image loading used for textures.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  38. Post #2918
    ArgvCompany's Avatar
    June 2012
    549 Posts
    Sorry I am being dumb, basically it is an OpenGL program and most of the things (assuming that OpenGL ES can run on a computer) functions in the same way. The notable differences are input and image loading used for textures.
    AFAIK, OpenGL ES is just a subset of OpenGL.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Agree Agree x 2 (list)

  39. Post #2919
    Gold Member
    Parakon's Avatar
    November 2008
    8,520 Posts
    I'm trying to compile some code I downloaded, but it keeps throwing this error up

    Code:
    fatal error LNK1104: cannot open file 'LIBCD.lib'
    whats the deal
    Reply With Quote Edit / Delete Windows 7 Canada Show Events Dumb Dumb x 1 (list)

  40. Post #2920
    Richy19's Avatar
    May 2010
    5,406 Posts
    I'm trying to compile some code I downloaded, but it keeps throwing this error up

    Code:
    fatal error LNK1104: cannot open file 'LIBCD.lib'
    whats the deal
    http://lmgtfy.com/?q=fatal+error+LNK...BCD.lib%27&l=1
    Reply With Quote Edit / Delete Linux United Kingdom Show Events Dumb Dumb x 6 (list)