• What do you need help with? Version 5
    5,752 replies, posted
[QUOTE=garychencool;38513722]Need help making this function in Python 2.5[/QUOTE] What help do you need? Do you understand how the check digit is calculated? Because all you need to do is manipulate the digits in the code so that the check digit is given to you. Then you'll have to compare the check digit you've acquired with the check digit that's in the code. read : [url]http://en.wikipedia.org/wiki/Universal_Product_Code#Check_digits[/url]
[QUOTE=Felheart;38513006]edit2: With anti-aliasing off, it fixes the issue when being near the blocks. But it's still there when viewing them from a distance. Also I want to keep AA.[/QUOTE] It will be because all your textures are on a sheet, it's sampling the adjacent textures on the sheet. There's no easy way to solve it, just use texture arrays instead.
[QUOTE=Fetret;38503957]I have been (somewhat successfully) trying to implement RK4 integration with help from the Gaffer on Games tutorial ([url]http://gafferongames.com/game-physics/integration-basics/[/url]), however I seem to be failing in achieving a MKS system. I am trying to make sure each pixel is equivalent to 1 meter, which I think is the direct result of implementing the above tutorial with no change, however especially when I add momentum and force things start going a bit pear shaped. In my mind, after implementing proper gravitational force and no drag, a fall of 200 pixels should be equivalent to a fall of 200 meters, which should take about 6.4 seconds, however this doesn't seem to be the case. So either I am fucking something up implementing force/momentum/velocity derivation, or something else is at play (to be clear, with gravity defined as 9.8 m/s2, it takes the particle far far longer than 6 seconds to move anywhere at all). I can/will post the relevant code if anyone would care to comment/help. But any general tips and tricks regarding physics simulation and RK4 with force/momentum is also appreciated![/QUOTE] How long does it take for an object to fall 200 pixels in your simulation?
[QUOTE=garychencool;38513722]Need help making this function in Python 2.5[/QUOTE] you should be able to do this, it's pretty basic, [code] def is_UPC(x): if len(x) == 12 and x.isdigit(): #checking if length is correct, and if it's numerical oddSum = 0 evenSum = 0 checkDgt = int(x[-1]) #put check digit in a var x = x[:-1] #remove check digit from string for i in range(1, 12): if i%2: oddSum += int(x[i-1]) else: evenSum += int(x[i-1]) result = (oddSum * 3 + evenSum)%10 if result: #checking if result is 0 result = 10 - result return result == checkDgt else: return False print is_UPC("036000291452") #should be true print is_UPC("036000291459") #false print is_UPC("faaaaaaaaart") #false [/code] i hope this isn't awful, I've never shown my code to anyone really [editline]19th November 2012[/editline] [QUOTE=laylay;38514350]It will be because all your textures are on a sheet, it's sampling the adjacent textures on the sheet. There's no easy way to solve it, just use texture arrays instead.[/QUOTE] Pretty sure that it's showing what's behind the cubes rather than the next texture, I've seen this happen in Minecraft and other games. The issue you're talking about it something else. If you want to make sure it's not the texture sampling the adjacent you could make the adjacent textures the same and see if it still happens.
The issue I'm talking about is the only issue he has. If the problem doesn't show up with aa and af off then it's sampling outside the sub regions of the sheet. Texture arrays will fix the problem and you won't have to worry about it again. You can even keep them on a sheet, just call glTexSubImage3D for each region.
[QUOTE=Swebonny;38514337]What help do you need? Do you understand how the check digit is calculated? Because all you need to do is manipulate the digits in the code so that the check digit is given to you. Then you'll have to compare the check digit you've acquired with the check digit that's in the code. read : [url]http://en.wikipedia.org/wiki/Universal_Product_Code#Check_digits[/url][/QUOTE] First Year Python :suicide:
[QUOTE=garychencool;38517346]First Year Python :suicide:[/QUOTE] you'd learn better if you actually tried to do your homework yourself rather than just posting your assignments here for us to do
[QUOTE=ahdge;38512051]Always [editline]19th November 2012[/editline] No idea why I quoted that and responded with that. [code] if(glfwGetKey(GLFW_KEY_LEFT) == GLFW_PRESS) { keytoggle = !keytoggle; if(keytoggle) { inc = !inc; } } r+=keytoggle?inc?r++:r--:0; [/code] Or something like that[/QUOTE] Okay, this doesn't work, so I'm just going to give this up for now.
[QUOTE=swift and shift;38517384]you'd learn better if you actually tried to do your homework yourself rather than just posting your assignments here for us to do[/QUOTE] I did try. I got most of it done already, just missing some validation related stuff.
Hello, I have a question regarding a vector based movement on a Unity 3D entity. But I don't think you need to require unity knowledge to asnwer it. I have an entity in my scene that can only move in 2D space (sidescrolling) and its velocity can be affected by multiple triggers (push, pull, etc.). I've been trying to implement a movement system that allows for loops and twists and turns in a 2d space using velocity only but with no good results. So far I've been applying a certain velocity based on maths every frame or so for X time (the time of the movement) but there's been 2 major problems: It doesn't react well with the triggers (that pushes and pull) because my function Sets a velocity and doesn't modify the actual one with a new trajectory. Its not smooth, every X time I can see the ball clearly changing trajectory which makes for an unrealistic and annoying experience. Here's an image of what I'm trying to achieve: [IMG]http://i4.photobucket.com/albums/y120/CrashBaco/loop.png[/IMG] Many thanks to anyone who tries to help.
[QUOTE=Felheart;38512464] Wow, that line really looks like you spend some time to make it hard to read. Keep in mind that the guy who asked this question is new to programming. No need to show him "obfuscated" code :P[/QUOTE] You're probably right but I wasn't intentionally trying to mask it's meaning. I find the ?: shortcut comes in handy once in a while and if others don't know what it is then maybe they'll be motivated to learn something new. I messed it up anyway it should be [code] r+=keytoggle?inc?1:-1:0; [/code] I read it as [code] if keytoggle then if inc then r+=1 else r+=-1 else r+=0 [/code]
How can you avoid Java GUI freezing while performing some operation/task? When I click Start in program it freezes for few seconds so the progress bar doesn't upgrade. Any suggestions?
[QUOTE=laylay;38514350]It will be because all your textures are on a sheet, it's sampling the adjacent textures on the sheet. There's no easy way to solve it, just use texture arrays instead.[/QUOTE] Well it also happens if I scale the texture to 100x (so it's just a single color)! So it can't be sampling neighbor pixels. What Shadaez said is right. Those lines indeed show what is behind the cubes. I changed the cubes behind the cube with artifacts to use another texute, and the artifact lines change! It's not some texture-sampling error. [editline]20th November 2012[/editline] [QUOTE=arleitiss;38524361]How can you avoid Java GUI freezing while performing some operation/task? When I click Start in program it freezes for few seconds so the progress bar doesn't upgrade. Any suggestions?[/QUOTE] [URL]http://stackoverflow.com/questions/940913/how-to-prevent-swing-gui-locking-up-during-a-background-task[/URL] [editline]20th November 2012[/editline] Screen with 4xAA and Texture coordinates scaled by 1.0/1000.0 [IMG]http://i.imgur.com/JRyJk.png[/IMG] In this pic we can see pretty good that its 100% not a sampling error. Look at the dark-brown block directly above the green block in the lower left corner of the picture. You can see that the green color of the block below leaks trough. The same is true for all other artifacts. The rendering artifacts really show what is rendered behind them. Screen with 0xAA and same Texture scale: [IMG]http://i.imgur.com/BMYiw.png[/IMG] See the 3 yellow points on the gray cube. Somehow the artifacts are STILL there even with 0xAA! But they're not visible across the whole line. (AA only exaggerates the error it seems)
That's not happening in the screens you showed, you'd have to intentionally offset your vertices or have 0 alpha pixels to see behind. Even in them pictures it doesn't look like it's showing what's behind, look at the pixel colours. It would help if you took a higher resolution picture.
I'm aware that it looks like that. But I'm really not modifying the vertices to "stand out" I tried rounding them to the nearest multiple of 0.5 but that didn't help either. I'll try to get a picture of the problem in a higher res... [editline]20th November 2012[/editline] Bigger picture here: [url]http://i.imgur.com/Ap92L.png[/url]
make the background 255,0,255, then it will be obvious if it's the issue. If you look here [img]http://puu.sh/1shRc[/img] there's a dark block behind it so shouldn't the line be dark, if it's showing through? If you compare every like-coloured block with eachother, all the outlines are the same color and it's not always the color of the block behind it.
laylay I have to apologize! I scaled the texture around its center by 2 pixels (so each block lost 2 pixels of the texture on every side) and the artifacts are gone! You said I should use texture arrays, I'll try that, thanks :) Someone know any good tutorials on how to use a texturearray?
unless you're rending the inside of the block and it's that color, but that would be weird
[QUOTE=Felheart;38524721]laylay I have to apologize! I scaled the texture around its center by 2 pixels (so each block lost 2 pixels of the texture on every side) and the artifacts are gone! You said I should use texture arrays, I'll try that, thanks :) Someone know any good tutorials on how to use a texturearray?[/QUOTE] This is all you need really, simple stuff. Much better than a single sheet and you wont run into any artifacts. [URL="http://www.opengl.org/wiki/Array_Texture"]http://www.opengl.org/wiki/Array_Texture [/URL] So you'll still be able to draw different textured blocks with a single draw call, each vertex will need a texture id though, which isn't a big deal.
Hey everyone, I'm doing a shitty VB program for my A-Level work and it is supposed to be able to open an access database and edit it etc. Everything works well until it comes to actually updating the database with a command builder, it crashes the second I click update and it seems like the command builder thing is making some stupidly long SQL code which doesn't fit. The error I get is: Syntax error (missing operator) in query expression '((CustomerID = ?) AND ((? = 1 AND FirstName IS NULL) OR (FirstName = ?)) AND ((? = 1 AND LastName IS NULL) OR (LastName = ?)) AND ((? = 1 AND Address IS NULL) OR (Address = ?)) AND ((? = 1 AND PostCode IS NULL) OR (PostCode = ?)) AND ((? = 1 AND Town IS N'. I don't really know much about SQL, I was told that the command builder thing would do it for me. It also seems to just run out. Any ideas?
[QUOTE=ahdge;38522339]You're probably right but I wasn't intentionally trying to mask it's meaning. I find the ?: shortcut comes in handy once in a while and if others don't know what it is then maybe they'll be motivated to learn something new. I messed it up anyway it should be [code] r+=keytoggle?inc?1:-1:0; [/code] I read it as [code] if keytoggle then if inc then r+=1 else r+=-1 else r+=0 [/code][/QUOTE] You should still probably use parentheses (and spaces, Jesus Christ) for the sake of clarity: [code]r += keytoggle ? (inc ? 1 : -1) : 0;[/code]
[QUOTE=CrashLemon;38521468]Hello, I have a question regarding a vector based movement on a Unity 3D entity. But I don't think you need to require unity knowledge to asnwer it. I have an entity in my scene that can only move in 2D space (sidescrolling) and its velocity can be affected by multiple triggers (push, pull, etc.). I've been trying to implement a movement system that allows for loops and twists and turns in a 2d space using velocity only but with no good results. So far I've been applying a certain velocity based on maths every frame or so for X time (the time of the movement) but there's been 2 major problems: It doesn't react well with the triggers (that pushes and pull) because my function [b]Sets a velocity and doesn't modify the actual one with a new trajectory.[/b] Its not smooth, every X time I can see the ball clearly changing trajectory which makes for an unrealistic and annoying experience. Here's an image of what I'm trying to achieve: [IMG]http://i4.photobucket.com/albums/y120/CrashBaco/loop.png[/IMG] Many thanks to anyone who tries to help.[/QUOTE] That's the solution: instead of setting the velocity vector, each time a force modifies it, just add the new vector to it.
[QUOTE=ThePuska;38526143]That's the solution: instead of setting the velocity vector, each time a force modifies it, just add the new vector to it.[/QUOTE] Sort of like actual force (Though isn't it more like impulse if you're modifying velocity and not acceleration)
Yeah. If you absolutely don't want to have an acceleration, it's physically equivalent to just integrate the acceleration to a delta of velocity, but you're limiting yourself to only applying impulses of forces, instead of using forces themselves. That's not a problem though if your timestep is fixed, or if you always know how long a force is going to be applied
So I'm making an Android app as a project, and it needs to have a login system. I was wondering however, how do I communicate with a server to check if the login is correct? Do I use sockets, XML or what?
[QUOTE=laylay;38524819]This is all you need really, simple stuff. Much better than a single sheet and you wont run into any artifacts. [URL="http://www.opengl.org/wiki/Array_Texture"]http://www.opengl.org/wiki/Array_Texture [/URL] So you'll still be able to draw different textured blocks with a single draw call, each vertex will need a texture id though, which isn't a big deal.[/QUOTE] Can't get it to work somehow... TexCoords.xyz are definitly correct (mapped them to color), but somehow "texture2DArray" always returns "0,0,0,0". How exactly do I have to bind the texture array now? GL.BindTexture(TextureTarget.Texture2DArray, texArray); vertex shader: [code]void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; gl_TexCoord[0] = gl_MultiTexCoord0; gl_FrontColor = gl_Color; } [/code] fragment shader: [code] #extension GL_EXT_gpu_shader4 : enable uniform sampler2DArray tex; void main() { int layer = int(gl_TexCoord[0].z + 0.5); gl_FragColor = texture2DArray(tex, vec3(gl_TexCoord[0].x, gl_TexCoord[0].y, layer)); } [/code] When I map the texture coordinates to the color then the values look valid. [IMG]http://i.imgur.com/yY9nP.png[/IMG] Maybe GL.BindTexture(TextureTarget.Texture2DArray, texArray); is wrong? Or I need to unbind the the 2D texture? [editline]20th November 2012[/editline] [QUOTE=FlashStock;38528064]So I'm making an Android app as a project, and it needs to have a login system. I was wondering however, how do I communicate with a server to check if the login is correct? Do I use sockets, XML or what?[/QUOTE] Depends. I guess you write your login server yourself? If its a small project then networkstreams (or just raw sockets) will be easy. A HTTP-Get request might be even easier, depening on your framework.
[QUOTE=Felheart;38528425]but somehow "texture2DArray" always returns "0,0,0,0". [/QUOTE] Does it still do that if you use 0 or some other value for the layer? Binding is the same as before but with GL_TEXTURE_2D_ARRAY as the target.
Got it. Who would have thought that you actually HAVE TO set Min/Mag Filters and WrapS WrapT parameters for it to work. I don't remember setting those for normal 2D textures and they worked anyway... Maybe this is a OpenTK thing? Shouldn't it initialize the filters and parameters to valid values? I just checked it and all those parameters are set to "0" (as in int(0)) Well, 8xAA, and no strange lines :D [IMG]http://i.imgur.com/r2kSi.png[/IMG] Big thanks to everyone (and especially laylay) for helping :D
Hey, i'm having a problem with the C buffer for strings. Basically it's a simple Hangman game where the user enters a word less than 6 characters, and the user has to guess character by character what the word is. However the problem i'm having is that when I ask for a character, if I put in multiple characters, it will read each one and check each one and go through the loop, technically it's still correct. But I want to correct this by only allowing someone to put in one character at a time. Sample CORRECT output, where the user only enters one letter at a time: [code]Enter a word (up to 6 characters): booby Welcome to H A N G M A N You must attempt to guess a word of length 5 ----- Guess 1 of 10 Guess a letter b Correct guess! b--b- Guess 2 of 10 Guess a letter o Correct guess! boob- Guess 3 of 10 Guess a letter y Correct guess! You win! You guessed the word: booby in 4 guesses![/code] And sample output that's WRONG, where the user enters a full word as a guess, the loop will continue to run and check each letter, but how do I prevent this, like an error checking loop to make sure the buffer only reads one character or tells the user to try again? [code]Enter a word (up to 6 characters): booby Welcome to H A N G M A N You must attempt to guess a word of length 5 ----- Guess 1 of 10 [B]Guess a letter booby[/B] Correct guess! b--b- Guess 2 of 10 [B]Guess a letter[/B] //Notice it's blank but the buffer reads the next letter 'o' Correct guess! boob- Guess 3 of 10 [B]Guess a letter[/B] //checks 'o' again You've already guessed that letter... boob- Guess 3 of 10 [B]Guess a letter[/B] You've already guessed that letter... boob- Guess 3 of 10 [B]Guess a letter[/B] Correct guess! You win! You guessed the word: booby in 4 guesses![/code] The section of code in question is the line with the ton of asterisks. [code]#include <stdio.h> #include <string.h> //Displays the users result of their guess void displayResult(int letterFound){ if(letterFound==1){ printf("\nCorrect guess!\n"); }else if(letterFound==0){ printf("\nSorry! Letter not found.\n"); }else if(letterFound==3){ printf("\nYou've already guessed that letter...\n"); } } //Searches the word, returns a 0 if not found, returns a 1 if found int searchWord(char c, char* d, char* w, int wordLength){ int letterFound=0; int i; for(i=0;i<wordLength;i++){ if(w[i]==c){ if(d[i]==c){ //Will return a 3 to not penalize player for guessing same letter letterFound=3; }else{ d[i]=c; letterFound=1; } } } return letterFound; } void playHangman(){ //the user's word (only 6 characters) char word[6]; //user's guess char guess; //the word's length int wordLength; //error checking variable int error=1; while(error!=0){ //The user's word printf("\nEnter a word (up to 6 characters): "); scanf("%s",word); wordLength=strlen(word); if(wordLength>6){ printf("\n\nWord too long, please try again\n\n"); }else{ error=0; } }//end error check //input has been received, so start the game printf("\nWelcome to H A N G M A N\nYou must attempt to guess" " a word of length %d\n", wordLength); char display[wordLength]; int i; for(i=0;i<wordLength;i++){ display[i]='-'; } int wordIsFound=0; //if word is found it holds 0, otherwise if it is completely found int numGuesses=1; int letterFound=0; while(wordIsFound==0&&numGuesses<10){ //show the word with dashes, as user to guess a letter printf("\n\n%s\n\n",display); //show user number of guesses printf("\nGuess %d of 10\nGuess a letter ",numGuesses); [B] //BUFFER IS READING MULTIPLE CHARACTERS...************************************* scanf(" %c",&guess); [/B] //increment the number of guesses numGuesses++; /*pass the user's guess, display word and the actual word, (by reference) *to search the word and return if a letter was found or not*/ letterFound=searchWord(guess,display,word,wordLength); /*If the letter has already been found, notify the player (done in displayResult function) *and decrement the number of guesses as to not penalize the player*/ if(letterFound==3){ numGuesses--; } displayResult(letterFound); /*if the words are lexicographically the same, the function will return 0 *therefore the word is found and set to 1, to stop the loop*/ if(strcmp(display,word)==0){ wordIsFound=1; } if(wordIsFound==1){ printf("You win!\nYou guessed the word: %s in %d guesses!\n\n",word,numGuesses); }else if(numGuesses==10){ printf("You lose! You were unable to guess the word %s in under 10 guesses.",word); } }//end while loop } int main(void){ playHangman(); return 0; }//end main[/code]
-snip- i'm dumb
Sorry, you need to Log In to post a reply to this thread.