• What Do You Need Help With? V6
    7,544 replies, posted
[QUOTE=Asgard;40675864]-snip- [editline]17th May 2013[/editline] Small Lua problem [url]https://gist.github.com/CptAsgard/89feb1d04d7531923d31[/url] Shouldn't OhDearImDying.lua load in all the functions from Health.lua once OhDearImDying.lua is read? It can't seem to find the HEALTH table that contains the functions. It's for a Firefall addon. Haven't really done Lua before.[/QUOTE] How are you using it? You should do [code]local HEALTH = require('Health')[/code] [QUOTE=Asgard;40676219]Can I check with Lua if the required file loaded correctly?[/QUOTE] Lua will error. In order to catch it instead of Lua terminating the execution you need to use pcall().
[QUOTE=Over-Run;40676308]Tried it, still no luck :S any other suggestions?[/QUOTE] Create a breakpoint on the Close() line and check to see if that code is actually being reached
[QUOTE=SteveUK;40676532]Create a breakpoint on the Close() line and check to see if that code is actually being reached[/QUOTE] Yeah the code is being reached :S
I'm loading in a BufferedImage in java doing [code]ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); InputStream input = classLoader.getResourceAsStream(name); return ImageIO.read(input);[/code] but it takes like forever to load just one small 256x64 pixel png image on semi-old computers (goes p fast on my computer). Is there any way to speed this up?
What is the best approach for executing a mailer script, one that will check a database table or a file directory for entries? Do I have a [url=https://en.wikipedia.org/wiki/Cron]cron[/url] job run this mailer script every 5-10 minutes? Or do I run this mailer script with [url=https://en.wikipedia.org/wiki/Nohup]nohup[/url] looped infinitely? This is the first time I've been in such a situation, so I am really interested in which will outperform the other, in the long run. I appreciate anyones feedback!
I'd use a cronjob
Check out [url=https://en.wikipedia.org/wiki/Inotify]inotify[/url].
[QUOTE=ZeekyHBomb;40688907]Check out [url=https://en.wikipedia.org/wiki/Inotify]inotify[/url].[/QUOTE] So I would have Apache drop a file into a specific directory it has permission to, to then have this report of it to my mailer script? [editline]18th May 2013[/editline] Such as "/var/www/notify", with my mailer script at "/var/www/mailer.php"?
There's a [url=http://php.net/manual/en/book.inotify.php]PHP binding for inotify[/url].
How do people usually handle multiple textures (like one texture for the wall in a room, one for the floor) in OpenGL? Do people create separate VBOs/VAOs for each texture group, then bind a texture, draw one VAO/VBO, bind another texture then draw another VAO/VBO? If there some way to pass a texture id in through the glBufferData call like you would for colour or texture co-ordinates? Do people use a huge sprite sheet with multiple textures on it then use the texture coordinates to choose the texture? Everything I can think of seems like it would be inefficient and weird.
[QUOTE=Liquid Helium;40690491]How do people usually handle multiple textures (like one texture for the wall in a room, one for the floor) in OpenGL? Do people create separate VBOs/VAOs for each texture group, then bind a texture, draw one VAO/VBO, bind another texture then draw another VAO/VBO? If there some way to pass a texture id in through the glBufferData call like you would for colour or texture co-ordinates? Do people use a huge sprite sheet with multiple textures on it then use the texture coordinates to choose the texture? Everything I can think of seems like it would be inefficient and weird.[/QUOTE] All of the above really, try a few approaches and profile them for your situation.
can someone PLEASE check this out this has been the reason i have stopped trying to develop a game engine and if i get it to work i will regain the will to work [url]http://stackoverflow.com/questions/16628515/text-not-rendering-at-all-with-freetype-glfw[/url] please [editline]18th May 2013[/editline] also python [code]divisorSums = {} def sumDivisors(num): global divisorSums total = 0 if num == 1: return 1 for i in xrange(num/2, 0, -1): if i in divisorSums: return divisorSums[i] else: if not num % i: total += i divisorSums[num] = total return total for i in range(100): print 'Sum of divisors of %i: %i\n' % (i, sumDivisors(i))[/code] this just outputs 1 for every number help i thought i knew how to memoize :(
-snip-
Does anyone here know about black-box testing? I have a test tomorrow and so I am going through past papers and one of the questions is: [QUOTE]Question 10 Consider the following trivial implementation of a clock in Java: [CODE] public class Clock { private int hours, minutes, seconds; // Method called by the operating // system, increases the time kept by the stop watch by 1 second public Clock secondElapsed(){ seconds = seconds + 1; // Line 1 if (seconds == 60) { // Line 2 seconds = 0; // Line 3 minutes = minutes + 1; // Line 4 } if (minutes == 60) { // Line 5 minutes = 0; // Line 6 hours = hours + 1; // Line 7 } if (hours == 24) // Line 8 hours = 0; // Line 9 return this; // Line 10 } }[/CODE] Program 4. What are the equivalence-classes for the values that the fields of class Clock may take in the execution of secondElapsed()? [A] seconds: [0-59], [60]; minutes: [0-59], [60]; hours: [0-23], [24] [B] seconds: [0-58], [59]; minutes: [0-58], [59]; hours: [0-22], [23] [C] seconds: [1-59], [60]; minutes: [1-59], [60]; hours: [1-23], [24] [D] seconds: [1-58], [59]; minutes: [1-58], [59]; hours: [1-22], [23][/QUOTE] I think it would be A but I have no idea :S
[QUOTE=Richy19;40699557]Does anyone here know about black-box testing? I have a test tomorrow and so I am going through past papers and one of the questions is: I think it would be A but I have no idea :S[/QUOTE] I don't really understand the question but I'd guess B because the field gets set to 0 when it reaches 60?
[QUOTE=Richy19;40699557]Does anyone here know about black-box testing? I have a test tomorrow and so I am going through past papers and one of the questions is: I think it would be A but I have no idea :S[/QUOTE] B. Unless initialized to some ridiculous values, the execution of the function will never result in seconds or minutes being equal to 60 or hours being equal to 24. All the valid values are [0-59], [0-59], [0-23], which I suspect is what they mean by B.
[QUOTE=ThePuska;40699701]B. Unless initialized to some ridiculous values, the execution of the function will never result in seconds or minutes being equal to 60 or hours being equal to 24. All the valid values are [0-59], [0-59], [0-23], which I suspect is what they mean by B.[/QUOTE] The question is so weird though. equivalent classes? Wikipedia made it seem like some higher math kind of thing.
[QUOTE=mobrockers2;40699730]The question is so weird though. equivalent classes? Wikipedia made it seem like some higher math kind of thing.[/QUOTE] This is the wikipedia article that deals with equivalence classes in programming, but it doesnt really help me understand [url]http://en.wikipedia.org/wiki/Equivalence_partitioning[/url]
[QUOTE=Richy19;40699816]This is the wikipedia article that deals with equivalence classes in programming, but it doesnt really help me understand [URL]http://en.wikipedia.org/wiki/Equivalence_partitioning[/URL][/QUOTE] derp edit I think the answer should be C since if you use [0-59] you can't test for testcase [60] as [60] would become 0 and 0 is in your first test case.
-snip- Should've been posted in WAYWO
(C#) I want to open a text file (.txt) and add the text to a rich textbox and also want to be able to save it. I want to be able to decide where the file should be and where I get it. How do I do this?
[QUOTE=JohanGS;40701680](C#) I want to open a text file (.txt) and add the text to a rich textbox and also want to be able to save it. I want to be able to decide where the file should be and where I get it. How do I do this?[/QUOTE] [CODE] private void button3_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); } private void button2_Click(object sender, EventArgs e) { saveFileDialog1.ShowDialog(); } private void openFileDialog1_FileOk(object sender, CancelEventArgs e) { TextReader reader = new StreamReader(openFileDialog1.FileName); richTextBox1.Text = reader.ReadToEnd(); reader.Close(); } private void saveFileDialog1_FileOk(object sender, CancelEventArgs e) { TextWriter writer = new StreamWriter(saveFileDialog1.FileName); writer.WriteLine(richTextBox1.Text); writer.Flush(); writer.Close(); } [/CODE] (No error checking) I'm very sure there are alternate better ways but as simple as this is for what it does I guess.
reposting python [code]divisorSums = {} def sumDivisors(num): global divisorSums total = 0 if num == 1: return 1 for i in xrange(num/2, 0, -1): if i in divisorSums: return divisorSums[i] else: if not num % i: total += i divisorSums[num] = total return total for i in range(100): print 'Sum of divisors of %i: %i\n' % (i, sumDivisors(i))[/code] this just outputs 1 for every number help i thought i knew how to memoize :(
[QUOTE=CRASHFORT;40701760](No error checking) I'm very sure there are alternate better ways but as simple as this is for what it does I guess.[/QUOTE] Can you limit it so that you only can read .txt-files?
In the properties you can set what extensions to allow.
[U]Also posted on Raspberry Pi forums but you guys are talented[/U] How would I go about making a gui with two buttons to rotate a stepper motor clockwise or counter-clockwise? I've tried doing it with Tkinter but the function "stepper" requires two arguments and I don't know how to do that. Pretty much I just have a button that calls "stepper" when clicked, but I don't know how to pass the two arguments with it. Sorry for not explaining well, I really don't know how to put it into words. The code I'm using for the motors (without the tkinter) [code]import RPi.GPIO as gpio import time PINS = [22,21,18,17] SEQA = [(22,),(22,21),(21,),(21,18),(18,),(18,17),(17,),(17,22)] RSEQA = [(17,),(17,18),(18,),(18,21),(21,),(21,22),(22,),(22,17)] DELAY = 0.002 gpio.setmode(gpio.BCM) for pin in PINS: gpio.setup(pin, gpio.OUT) def stepper(sequence, pins): for step in sequence: for pin in pins: gpio.output(pin, gpio.HIGH) if pin in step else gpio.output(pin, gpio.LOW) time.sleep(DELAY) try: while True: for _ in xrange(512): stepper(SEQA,PINS) # forward for _ in xrange(512): stepper(RSEQA,PINS) # reverse except KeyboardInterrupt: gpio.cleanup()[/code] and this is the line of code I will be using for the button [code]clockwise = Button(master, text="clockwise", bg="black", fg="green", repeatdelay="500", repeatinterval="100", command=stepper) clockwise.grid(row=5, column=0) [/code]
[QUOTE=dvondrake;40705347]Having a bit of trouble with making my shadows soft. [code]float visibility = 1.0; for (int i=0; i<4; i++) { float sample = texture( tShadowMap, ShadowCoord.xy + poissonDisk4[i]/700 ).z; //if ( sample < ShadowCoord.z ) visibility -= 0.2 * (1.0 - sample); }[/code] If I leave the depth comparison out, I get [url=http://i.imgur.com/MREdcrO.png]the intended result[/url]. However, [url=http://i.imgur.com/gWYOUZK.png]it shadows the front side of the model too[/url]. If I uncomment it the front side of the model is no longer shadowed, but [url=http://i.imgur.com/GYkGdgG.png]then the shadow looks really bad[/url]. I think because the depth within the shadow is less than ShadowCoord depth but there's a bit outside of the shadow where it blurs that's greater than ShadowCoord depth too, and then the front side of the model is greater than ShadowCoord depth as well. Any ideas? Really not sure where to go from here.[/QUOTE] Random thought: <= instead of < ? I don't know much about shadowing, and especially not enough about your particular example.
Anyone know a good sprite sheet and collision tutorial for slick2d? For collision I'm using the Tiled program but I have the two players in seperate classes from the main class, so when I try to check for collision in the player class it conflicts with the update method in the main class. I can't put the collision stuff in the main class since I need two desperate ones for two players and it checks in their keystrokes, I'll post the code later
[QUOTE=DesolateGrun;40710228]Anyone know a good sprite sheet and collision tutorial for slick2d? For collision I'm using the Tiled program but I have the two players in seperate classes from the main class, so when I try to check for collision in the player class it conflicts with the update method in the main class. I can't put the collision stuff in the main class since I need two desperate ones for two players and it checks in their keystrokes, I'll post the code later[/QUOTE] Are you saying that you have two separate classes for the two different kinds of player movement controls? Just use a flag for that. Having your player class check for collision at the latest possible point and setting it's velocity to 0 when colliding is what works for me. So you want to keep your horizontal velocity and vertical velocity separate, and apply any movement speed when moving to those variables, check for collision, if colliding set the appropriate velocity to 0, and apply the velocity variables to the player position.
[QUOTE=Asgard;40710546]Are you saying that you have two separate classes for the two different kinds of player movement controls? Just use a flag for that. Having your player class check for collision at the latest possible point and setting it's velocity to 0 when colliding is what works for me. So you want to keep your horizontal velocity and vertical velocity separate, and apply any movement speed when moving to those variables, check for collision, if colliding set the appropriate velocity to 0, and apply the velocity variables to the player position.[/QUOTE] I have the project set up as so [img]http://i.imgur.com/xTQR178.png[/img] and here's the code for movement in each entity(which is a player) [code]public class Entity { protected Vector2f pos; protected Rectangle box; protected Image sprite; private boolean[][] blocked; private static final int SIZE = 50; private float x = 50f, y = 50f; Entity player_l; public Entity(float x, float y, int width, int height, Image sprite) { pos = new Vector2f(x,y); box = new Rectangle(x, y, width, height); this.sprite = sprite; } public void update(GameContainer gc, int mapWidth, int mapHeight, int delta) { Vector2f trans = new Vector2f(0, 0); // Vector contains a value with components x & y Input input = gc.getInput(); if (input.isKeyDown(Input.KEY_W)) // Delta is used to move things on a frame rate independent way { //if(isBlocked(x, y + SIZE + delta * .4f)){ trans.y = -0.4f * delta; } if (input.isKeyDown(Input.KEY_S)) { //if (!isBlocked(x, y + SIZE + delta * 0.1f)) trans.y = 0.4f * delta; } if (input.isKeyDown(Input.KEY_D)) { //if (!isBlocked(x + SIZE + delta * 0.1f, y)) trans.x = 0.4f * delta; } if (input.isKeyDown(Input.KEY_A)) trans.x = -0.4f * delta; //{ // if (!isBlocked(x, y)) // x = 0; //player_l.render(); //} if (trans.x != 0 && trans.y != 0) { // If both components aren't null, we reduce them to have constant speed on all directions trans.set(trans.x / 1.5f, trans.y / 1.5f); } if(pos.x+trans.x > 30 && pos.x+trans.x < (mapWidth-80)) //We add (subtract) because of the stone wall pos.x += trans.x; if(pos.y+trans.y > 30 && pos.y+trans.y < (mapHeight-100)) pos.y += trans.y; } public void render() { sprite.draw(pos.x, pos.y); } [B] public boolean isBlocked(float x, float y) { int xTile = (int) (x / 50); int yTile = (int) (y / 50); return blocked[xTile][yTile]; }[/B] // Getters and Setters public Vector2f getPos() { return pos; } public float getX() { return pos.x; } public float getY() { return pos.y; } public void setPos(Vector2f pos) { this.pos = pos; } public Rectangle getBox() { return box; } public void setBox(Rectangle box) { this.box = box; } public Image getSprite() { return sprite; } public void setSprite(SpriteSheet sprite) { this.sprite = sprite; } }[/code] And the bolded part is the check for intersection with the blocked tiles, which is declared in the main class Game. [code] blocked = new boolean[map.getWidth()][map.getHeight()]; for (int x=0;x<map.getWidth();x++) { for (int y=0;y<map.getHeight();y++) { System.out.println(x + " " + y); int id = map.getTileId(x, y, 0); String value = map.getTileProperty(id, "blocked", "true"); if (value.equalsIgnoreCase("true")) { System.out.println(value); blocked[x][y] = true; } } }[/code] Here, but if I put code in the entities movement keys, it crashes [code] if (input.isKeyDown(Input.KEY_A)) { if (!isBlocked(x - delta * 0.1f, y)) trans.x = -0.4f * delta; //player_l.render(); }[/code] [quote]Mon May 20 16:11:08 EDT 2013 ERROR:null java.lang.NullPointerException at onionrogue.Entity.isBlocked(Entity.java:85) at onionrogue.Entity.update(Entity.java:58) at onionrogue.Game.update(Game.java:98) at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:678) at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:456) at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:361) at onionrogue.Game.main(Game.java:127) Mon May 20 16:11:08 EDT 2013 ERROR:Game.update() failure - check the game code. org.newdawn.slick.SlickException: Game.update() failure - check the game code. at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:684) at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:456) at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:361) at onionrogue.Game.main(Game.java:127) BUILD SUCCESSFUL (total time: 5 seconds)[/quote] Im sorry for the wall of code but is there a more efficient and successful way of trying to do what Im doing?
Sorry, you need to Log In to post a reply to this thread.