• What do you need help with? Version 5
    5,752 replies, posted
[QUOTE=ShaunOfTheLive;36521269]Yeah, but then every time you open the spreadsheet it'll be like "MACROS MAY BE DANGEROUS WHARRGARBL"[/QUOTE] Only if you have the security stuff turned on :v:, you can turn it off entirely. but it does open you up to some damaging macros.
[lua] audio = "/Assets/Audio/" graphics = "/Assets/Graphics/" IsDown = love.keyboard.isDown function love.load() ship = love.graphics.newImage( graphics.."ship.png" ) bullet = love.graphics.newImage( graphics.."bullet.png" ) x = 200 y = 200 speed = 200 rotation = 0 BulletSpeed = 100 end function love.draw() love.graphics.draw( ship, x, y, rotation, 1, 1, 63, 39 ) end function love.update( dt ) --normal directions if IsDown( "d" ) then x = x + ( speed *dt ) rotation = 1.6 elseif IsDown( "a" ) then x = x - ( speed * dt ) rotation = 4.7 end if IsDown( "s" ) then y = y + ( speed * dt ) rotation = 3.18 elseif IsDown( "w" ) then y = y - ( speed * dt ) rotation = 0 end --8 directional if IsDown( "d" ) and IsDown( "s" ) then rotation = 2.5 elseif IsDown( "a" ) and IsDown( "s" ) then rotation = 3.8 end if IsDown( "d" ) and IsDown( "w" ) then rotation = 0.5 elseif IsDown( "a" ) and IsDown( "w" ) then rotation = -0.8 end --controls if IsDown( " " ) then love.graphics.draw( bullet, x, y ) end end function love.keypressed( key ) if key == "escape" then love.event.push( "quit" ) end end [/lua] first time messing with LOVE, wondering if anyone can lend me a hand? i'm trying to use the space to spawn a "bullet" from the ship and have it just shoot off in a path..normal bullet..but either i'm not reading their wiki enough or i'm just too tired for this but i can't seem to figure out how to create an object at an origin and have it fly off.
First, create an object to contain all the bullets. When you press space, add an object to that container with the folloring properties: x, y, speedx, speedy, rotation. Each frame you loop through all the bullets where you add speedx to x and add speedy to y, and do bullet logic like destroying ships. Lastly ofcourse, draw all bullets using x, y and rotation.
I'm trying to code a roguelike using libtcod as a basic c++ project. I'm competent in Java and I used c++ long long ago but I'm really trying to do some OOP stuff now that I had never touched before. Basically what I am trying to do is define a base class Object that is used for everything, then a derived class Organism, that has stats and movement and that kind of thing, and finally a third class derived from Organism which is Player. I can derive Organism from Object just fine, but I run into problems when I try to derive Player from Organism. Why?
[QUOTE=Daggoth;36539347]I'm trying to code a roguelike using libtcod as a basic c++ project. I'm competent in Java and I used c++ long long ago but I'm really trying to do some OOP stuff now that I had never touched before. Basically what I am trying to do is define a base class Object that is used for everything, then a derived class Organism, that has stats and movement and that kind of thing, and finally a third class derived from Organism which is Player. I can derive Organism from Object just fine, but I run into problems when I try to derive Player from Organism. Why?[/QUOTE] Post code pls.
[code] //Object.h class Object { int x; int y; int c; char displayName[]; public: Object(int,int,int); void moveObj(int, int); void setPos(int,int); void setDisplayName(char[]); }; //Organism.h class Organism : public Object{ int HitPoints; void HandleTurn(); }; //Player.h class Player : public Organism { void HandleInput(); }; [/code]
[QUOTE=Daggoth;36539693][code] //Object.h class Object { int x; int y; int c; char displayName[]; public: Object(int,int,int); void moveObj(int, int); void setPos(int,int); void setDisplayName(char[]); }; //Organism.h class Organism : public Object{ int HitPoints; void HandleTurn(); }; //Player.h class Player : public Organism { void HandleInput(); }; [/code][/QUOTE] char DisplayName[] <-- This is bad. Very bad. Use const char *DisplayName. DisplayName[] is an unsized array which means your structs cannot be copied properly and initialization is strange. setDisplayName <-- Change that to accept const char* instead of char[]. You may want to also post whatever error messages you are getting.
[QUOTE=Sethorion;36521288]Hey guys, I've created a simple PHP script that uploads a file. It also allows you to create and edit text files as well as create directories. I got it to work ages a go but for some reason It's suddenly not working. If anyone here could look at it and try to get it working for me, I would MASSIVELY appreciate it. [url=http://www.gamefront.com/files/21910078/upload.zip]Here's the link to the code.[/url][/QUOTE] holy christ that is bad
[QUOTE=swift and shift;36547733]holy christ that is bad[/QUOTE] Could you elaborate on how and why it's bad, instead of just saying it is? You're not exactly being helpful to the developer.
[QUOTE=T3hGamerDK;36547907]Could you elaborate on how and why it's bad, instead of just saying it is? You're not exactly being helpful to the developer.[/QUOTE] [b]upload.php[/b] [php] <?php $dir = $_POST['name']; mkdir($dir); header("location: index.php"); ?> [/php] arbitrary directory creation anywhere in the filesystem the webserver can write to [b]delete.php[/b] [php] <?php $dir = $_GET['dir']; rmdir($dir); //$file = $_GET['name']; //unlink($file); header("location: index.php"); //$file = $_GET['name']; //$dir = $_GET['dir']; //unlink($file); //echo "File Deleted! <a href='index.php'>Click here to continue </a>"; ?> [/php] same thing but with deletion [b]index.php[/b] [php] <html> <form action="create.php" method="POST"> Enter the name of the folder: <input type="text" name="name"> <input type="submit" value="Create"> </form> <form method="post" enctype="multipart/form-data"> <input type="hidden" name="upload" value="1"> <input type="file" name="file"> <input type="submit" value="Upload"> </form> <p><a href="upload/index.php" >Click here to create, edit and delete a text document.</a></p> </html> <?php $path = "."; $dir = opendir($path) or die ("Unable to open directory"); while($file = readdir($dir)) { if($file == "." || $file == ".." || $file == "index.php" || $file == "upload" || $file == "delete.png" || $file == "create.php" || $file == "delete.php") continue; echo "<a href='$file'>$file</a><a href='delete.php?dir=$file'><img src='delete.png'></a><br>"; } closedir($dir); if($_POST[upload] == "1") { $to = "./".$_FILES['file']['name']; move_uploaded_file($_FILES['file']['tmp_name'], $to); echo "Uploaded"; print "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">"; } ?> [/php] data outputted as html is not properly sanitized, leading to an xss vulnerability. $_FILES["file"]["name"] is user controlled, hence there's an arbitrary file write vulnerability anywhere on the file system. [b]upload/create_file.php[/b] [php] <?PHP $pre_file_name = $_POST['name']; $ext = ".txt"; $file_name = $pre_file_name.$ext; fopen($file_name,'w'); ?> <html> <form action="edit_file.php" method="POST"> Enter Text: <BR> <textarea name="edit" cols="100" rows="20"></textarea> <input type="hidden" name="file_name" value="<?PHP echo $file_name ?>"> <input type="submit" value="Save"> </form> </html> [/php] xss vulnerability, arbitrary file creation/truncation anywhere on the filesystem [b]upload/delete.php[/b] [php] <?PHP $file = $_GET['name']; unlink($file); echo("File Deleted: <a href='index.php'> Click here to continue</a>") ?> [/php] arbitrary file deletion [b]upload/edit.php[/b] [php] <?PHP $file_name = $_GET['name']; $file_read = fopen($file_name,"r"); $contents = fread($file_read, filesize($file_name)); fclose($file_read); ?> <html> <form action="edit_file.php" method="POST"> <textarea name="edit" cols="100" rows="20"><?PHP echo ($contents);?> </textarea> <input type="hidden" name="file_name" value="<?PHP echo ($file_name); ?>"> <input type="submit" value="save"> </form> </html> [/php] arbitrary file read, xss [b]upload/edit_file.php[/b] [php] <?PHP $edit = $_POST['edit']; $file_name = $_POST['file_name']; $file = fopen($file_name, 'w'); fwrite($file, $edit); fclose($file); echo "File Saved <a href='index.php'> Click here to continue</a>"; ?> [/php] arbitrary file write [b]upload/index.php[/b] [php] <html> <a href="../index.php">Back</a> <form action="create_file.php" method="POST"> File Name:<input type="text" name="name"> <input type="submit" value="Create File"> </form> </html> <?PHP $full_path = "."; $dir = @opendir($full_path) or die ("unable to open"); while($file = readdir($dir)){ if($file == "." || $file == ".." || $file == "index.php" || $file == "create_file.php" || $file == "edit.php" || $file == "edit_file.php" || $file == "delete.php" ) continue; echo "<a href = '$file'>$file</a> .....<a href='edit.php?name=$file'>Edit </a> ..... <a href='delete.php?name=$file'>Delete</a><BR>"; } closedir($dir); ?> [/php] xss
I have a huge issue with OpenGLes 1 and Android NDK I can't enable or disable the GL_DEPTH_TEST flag natively, for some reason it just doesn't work. I would be grateful for a way to fix it, work around it or a method for calling java functions/broadcasting intents from the native app (NDK Lib) to my Java app. Thanks in advance
[QUOTE=JohnnyOnFlame;36551117]I have a huge issue with OpenGLes 1 and Android NDK I can't enable or disable the GL_DEPTH_TEST flag natively, for some reason it just doesn't work. I would be grateful for a way to fix it, work around it or a method for calling java functions/broadcasting intents from the native app (NDK Lib) to my Java app. Thanks in advance[/QUOTE] Have you set up a depth buffer? If you have call glGetLastError and see what comes up. [editline]29th June 2012[/editline] How the hell do I remove a google code project???
[QUOTE=flayne;36551579]Have you set up a depth buffer? If you have call glGetLastError and see what comes up. [editline]29th June 2012[/editline] How the hell do I remove a google code project???[/QUOTE] No, I didnt't setup one, and I don't know how do you do it. Also, glGetError gave me no decent clue.
I would like some advice if anyone knows the best frameworks for someone to use when developing for android phones? I'm experienced in OGRE, and Unity. But looking to branch out. :)
[QUOTE=JohnnyOnFlame;36552263]No, I didnt't setup one, and I don't know how do you do it. Also, glGetError gave me no decent clue.[/QUOTE] You can't use depth test without a depth buffer where's OpenGL going to get the depth's to test?
I want to try programming some 2d games in C#. Does anyone know where I might be able to get the source code for some games that I can refer to?
[QUOTE=Pelf;36554562]I want to try programming some 2d games in C#. Does anyone know where I might be able to get the source code for some games that I can refer to?[/QUOTE] google "open source c# game"
I'm trying to add a suffix to a file name in C, and then pass it into fopen as seen below. [cpp] int main() { char file_name[MAX_PATH], new_file_name[MAX_PATH]; char str[3] = { 'n', 'e', 'w' }; char ext[4] = { '.', 't', 'x', 't' }; new_file_name = &append_fname(file_name, str, ext); // how do I convert a char * into a char[]? fp = fopen(new_file_name, "w+"); // other code return 0; } char *append_fname(char fname[], char _str[], char _ext[]) { char new_fname[MAX_PATH]; char *ret; int i, j, k; int ls = sizeof(_str) / sizeof(char); int le = sizeof(_ext) / sizeof(char); for(i = MAX_PATH; i >= 0; i--) { if(fname[i] == '.') { for(j = 0; j < (ls + le); ++j) { if(j < ls) new_fname[i + j] = _str[j]; else new_fname[i + j] = _ext[j - ls]; } } else new_fname[i] = fname[i]; } ret = malloc(sizeof(new_fname)); if(ret == NULL) return NULL; ret = (char *)new_fname; return ret; } [/cpp] I'm not sure how to convert a char * into a char[]. Any ideas?
[QUOTE=swift and shift;36548411] php code [/QUOTE] I dont understand why this is an argument for php being bad?
[QUOTE=Richy19;36554869]I dont understand why this is an argument for php being bad?[/QUOTE] ..it isnt
how people usually load .obj objects in opelGL with SFML?
[QUOTE=Mete;36555073]how people usually load .obj objects in opelGL with SFML?[/QUOTE] I think a lot of people around here write their own parser, because .obj is a pretty simple format. Otherwise you can use a library like [url=http://people.cs.kuleuven.be/~ares.lagae/libobj/index.html]libobj[/url].
[QUOTE=MrTilepy;36554756]I'm trying to add a suffix to a file name in C, and then pass it into fopen as seen below. [cpp] int main() { char file_name[MAX_PATH], new_file_name[MAX_PATH]; char str[3] = { 'n', 'e', 'w' }; char ext[4] = { '.', 't', 'x', 't' }; new_file_name = &append_fname(file_name, str, ext); // how do I convert a char * into a char[]? fp = fopen(new_file_name, "w+"); // other code return 0; } char *append_fname(char fname[], char _str[], char _ext[]) { char new_fname[MAX_PATH]; char *ret; int i, j, k; int ls = sizeof(_str) / sizeof(char); int le = sizeof(_ext) / sizeof(char); for(i = MAX_PATH; i >= 0; i--) { if(fname[i] == '.') { for(j = 0; j < (ls + le); ++j) { if(j < ls) new_fname[i + j] = _str[j]; else new_fname[i + j] = _ext[j - ls]; } } else new_fname[i] = fname[i]; } ret = malloc(sizeof(new_fname)); if(ret == NULL) return NULL; ret = (char *)new_fname; return ret; } [/cpp] I'm not sure how to convert a char * into a char[]. Any ideas?[/QUOTE] First I don't think you understand char[]. char[] is interpreted by the compiler as char * and I recommend you use that type instead (never use unsized array types). Second that sizeof directive won't work. It will return 4 most likely, to get the size use strsize. Third you should make new_fname a dynamically allocated char* (use malloc after you have gotten the size that way you're not wasting space and don't have to be worried about a limit). As far as syntax goes you can treat new_fname as if it was the same old char[], you can get rid of ret, and you can return new_fname. PS. Your strings should be null terminated not period terminated if you don't know what this means you need to seriously research strings more.
Is there any reason I shouldn't represent a 2d array of characters as a 1d char array in C? A lot of operations seem more straightforward when it's a 1d array, but I feel like a 2d array is more intuitive all around.
[QUOTE=Richy19;36554869]I dont understand why this is an argument for php being bad?[/QUOTE] It's not; he's pointing out why the code itself is written badly. [editline]29th June 2012[/editline] [QUOTE=Rayjingstorm;36555295]Is there any reason I shouldn't represent a 2d array of characters as a 1d char array in C? A lot of operations seem more straightforward when it's a 1d array, but I feel like a 2d array is more intuitive all around.[/QUOTE] Don't take my word on this but I [I]think[/I] behind the scenes a 2D array is essentially the same as 1D array anyway. So just do whatever feels more natural and easy to you from a code standpoint.
[QUOTE=Rayjingstorm;36555295]Is there any reason I shouldn't represent a 2d array of characters as a 1d char array in C? A lot of operations seem more straightforward when it's a 1d array, but I feel like a 2d array is more intuitive all around.[/QUOTE] Well the only way to use a 2D array is to have all the strings be the same size. I don't think this would be practical for most purposes but there is no real reason not to unless you need it to be a return value or passed to functions (so it really only works as a global variable). As Chris220 mentions I'm pretty sure that 2D arrays are 1D arrays in the background. So id[1][3] is basically 1 + 3*number of columns.
[QUOTE=Richy19;36554869]I dont understand why this is an argument for php being bad?[/QUOTE] are you dumb
[QUOTE=swift and shift;36556006]are you dumb[/QUOTE] Rude, I simply didnt read your comments properly to get that you were outlining his code.
[QUOTE=swift and shift;36556006]are you dumb[/QUOTE] You should calm down, there's no need to shout at everyone who makes a tiny mistake. You do that all the time. [B] =====[/B] [img]http://new.tinygrab.com/7cfbd517837cc231f7920affab3240564bafc77c8f.png[/img] Of course..
[QUOTE=flayne;36553952]You can't use depth test without a depth buffer where's OpenGL going to get the depth's to test?[/QUOTE] No dude, like, I can enable/disable it, and it works. But problem is, that can only be done on the Java part of my app, when I really need it to work on the native, glEnable/Disableing it gives me nothing on native, while it DOES on the java part.
Sorry, you need to Log In to post a reply to this thread.