• What do you need help with? Version 5
    5,752 replies, posted
  • [QUOTE=JakeAM;37501872]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?[/QUOTE] 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#.
  • 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. [IMG]http://puu.sh/11cro[/IMG] [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; } [/code]
  • 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? [editline]2nd September 2012[/editline] 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?
  • [QUOTE=confinedUser;37504533]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)[/code][/QUOTE] Dunno really what the problem is, but if you use this condition, the program will quit if anyone get hit once.
  • [QUOTE=AlienCat;37507087]Dunno really what the problem is, but if you use this condition, the program will quit if anyone get hit once.[/QUOTE] 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
  • 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; }[/code]
  • 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 :)
  • [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))); [/code] something like that, I can't test it right now
  • [QUOTE=MakeR;37507411]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; }[/code][/QUOTE] oh so that's whats been getting me. Thanks :)
  • [QUOTE=Naelstrom;37503294]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#.[/QUOTE] 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.
  • 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.
  • [QUOTE=pryrotechfan;37508428]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.[/QUOTE] [URL="http://en.wikipedia.org/wiki/Quadtree"]http://en.wikipedia.org/wiki/Quadtree[/URL] [URL="http://www.codeproject.com/Articles/30535/A-Simple-QuadTree-Implementation-in-C"]http://www.codeproject.com/Articles/30535/A-Simple-QuadTree-Implementation-in-C[/URL] [URL="http://www.kyleschouviller.com/wsuxna/quadtree-source-included/"]http://www.kyleschouviller.com/wsuxna/quadtree-source-included/[/URL] [URL="http://blog.notdot.net/2009/11/Damn-Cool-Algorithms-Spatial-indexing-with-Quadtrees-and-Hilbert-Curves"]http://blog.notdot.net/2009/11/Damn-Cool-Algorithms-Spatial-indexing-with-Quadtrees-and-Hilbert-Curves[/URL] [URL="http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/quadtrees-r1303"]http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/quadtrees-r1303[/URL] As for octtrees I havent really looked yet, but its pretty much the same as quadtree, but with a nother dimension
  • [QUOTE=Richy19;37509041][URL]http://en.wikipedia.org/wiki/Quadtree[/URL] [URL]http://www.codeproject.com/Articles/30535/A-Simple-QuadTree-Implementation-in-C[/URL] [URL]http://www.kyleschouviller.com/wsuxna/quadtree-source-included/[/URL] [URL]http://blog.notdot.net/2009/11/Damn-Cool-Algorithms-Spatial-indexing-with-Quadtrees-and-Hilbert-Curves[/URL] [URL]http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/quadtrees-r1303[/URL] As for octtrees I havent really looked yet, but its pretty much the same as quadtree, but with a nother dimension[/QUOTE] Thanks for all the resources. I should be able to get it after this....hopefully.
  • [QUOTE=WTF Nuke;37504718]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? [editline]2nd September 2012[/editline] 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?[/QUOTE] 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.
  • 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 [cpp] #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 [/cpp] Then GLUtilMaster.hpp includes the utilities.hpp, and all classes include GLUtilMaster.hpp, I thought the ifndef... was meant to prevent this
  • [QUOTE=calzoneman;37510327]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.[/QUOTE] 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. [editline]2nd September 2012[/editline] So I am trying to speed up my drawing, and this is my current draw function. [cpp]{ 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); }[/cpp] 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?
  • 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.
  • [QUOTE=jung3o;37512894]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.[/QUOTE] 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.
  • 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?
  • [QUOTE=AlienCat;37514872]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?[/QUOTE] Depends on what you're doing.
  • 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; } [/code] Can someone tell me how to fix this, or tell me about a better way to execute this? Thanks :) [editline]3rd September 2012[/editline] 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 ^^
  • 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, [url=http://www.dotnetperls.com/switch-enum]with enums[/url]) and you don't want to create a giant if-else if block. You can turn each switch block into: [csharp] 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!"); [/csharp] 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.
  • [QUOTE=robmaister12;37515791]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, [url=http://www.dotnetperls.com/switch-enum]with enums[/url]) and you don't want to create a giant if-else if block. You can turn each switch block into: [csharp] 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!"); [/csharp] 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.[/QUOTE] 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 ^^
  • [QUOTE=Doom;37515861]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 ^^[/QUOTE] 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: [csharp]int points = 0; if (radioButtona.Checked) points += 1; //... MessageBox.Show(string.Format("You gained {0} affection points!", points));[/csharp]
  • going to attempt to learn c++ what do I need a compiler text editor and debugger? i haven't the faintest
  • 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?
  • [QUOTE=Parakon;37516806]going to attempt to learn c++ what do I need a compiler text editor and debugger? i haven't the faintest[/QUOTE] you could use code::blocks
  • [QUOTE=amcfaggot;37518275]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?[/QUOTE] I only get this issue when running with a debugger attached.