• What Do You Need Help With? V7
    4,993 replies, posted
Programming related help thread. [url=http://www.facepunch.com/threads/910202]Version 1[/url] [url=http://www.facepunch.com/threads/1053117]Version 2[/url] [url=http://www.facepunch.com/threads/1092921]Version 3[/url] [url=http://www.facepunch.com/threads/1152030]Version 4[/url] [url=http://facepunch.com/showthread.php?t=1167392]Version 5[/url] [url=http://facepunch.com/showthread.php?t=1250528]Version 6[/url]
[CODE]dynamicArray::dynamicArray(int initialSize) { buffer_ = new StoredData[initialSize]; size = initialSize; for (int i = 0; i <= size; i++) { buffer_[i] = StoredData(); } } void dynamicArray::growDouble() { int newSize = size ? size * 2 : 1; auto tempBuffer_ = new StoredData[newSize]; for (int i = 0; i < size; ++i) { tempBuffer_[i] = buffer_[i]; } for (int i = size; i < newSize; ++i) { tempBuffer_[i] = StoredData(); } delete [] buffer_; buffer_ = tempBuffer_; size = newSize; }[/CODE] Fix for the last post in the previous thread, person was trying to write outside the allocated block. Typing this on my phone so there may be mistakes.
I'm in the progress of learning C# after I was taught VB in school. And I've come up against a problem whilst converting an SDL platformer prototype I made. Declared class variable: [CODE] public plane myplane = null; [/CODE] Sometime later on in this player class [CODE] public void update() { if (myplane.Equals(null)) { [/CODE] Error returned is "object not set to an instance of an object". Why can't I do this in C#? Context is that variable only holds the reference to a plane object if the player is currently on one. I know I could have a Boolean testing weather the player is on a plane or not and never having to question if the myplane variable is null, but I preferred the approach I took in VB. Help would be much appreciated :)
[CODE] if (myplane == null) [/CODE]
[QUOTE=zero_slo;46929453][CODE] if (myplane == null) [/CODE][/QUOTE] Why thankyou!
[QUOTE=farmatyr;46927149][CODE]dynamicArray::dynamicArray(int initialSize) { buffer_ = new StoredData[initialSize]; size = initialSize; for (int i = 0; i <= size; i++) { buffer_[i] = StoredData(); } } void dynamicArray::growDouble() { int newSize = size ? size * 2 : 1; auto tempBuffer_ = new StoredData[newSize]; for (int i = 0; i < size; ++i) { tempBuffer_[i] = buffer_[i]; } for (int i = size; i < newSize; ++i) { tempBuffer_[i] = StoredData(); } delete [] buffer_; buffer_ = tempBuffer_; size = newSize; }[/CODE] Fix for the last post in the previous thread, person was trying to write outside the allocated block. Typing this on my phone so there may be mistakes.[/QUOTE] [del]Same thing happens. I'm not sure what do you mean by outside of the allocated block since I'm only messing with tempBuffer and it is supposed to accommodate all I'm trying to write to it as well has have extra space.[/del] My mistake, it all works now. Thanks!
In the constructor you are writing to buffer_[size], which is invalid. The valid indices are 0 to size-1. Also, when you create the array using new it will automatically use the default constructor to create each element. You don't have to do it manually.
[QUOTE=Fredo;46930634]In the constructor you are writing to buffer_[size], which is invalid. The valid indices are 0 to size-1. Also, when you create the array using new it will automatically use the default constructor to create each element. You don't have to do it manually.[/QUOTE] Oh, I see. Not sure why there was an equals in that loop. Simple overlook that caused so much confusion. I didn't bother looking for the problem past the growDouble function. Thanks.
Not help really, but looking for advice. Have a coding thing for a job on Friday. It's paired programming, so guy rings me up on Skype and I guess he shares his desktop with me and we code. Friend works in the company and said when he had to do it you basically took it in turns cleaning up code or something. Like he would write something with the interviewer commenting on it, and then the interviewer writes code and you have to talk about better approaches or whatever. Friend said to just practise OO principles and design stuff. Wondering has anybody been in a similar situation and able to offer any advice for it? Sort of a hard thing to practise for, but I need this job so any advice would be great.
Does anyone know or have a solution for this in C++: I have time, date, latitude and longitude and using this information I need to get sun position in pitch, roll and yaw. I have checked [URL]http://williams.best.vwh.net/sunrise_sunset_algorithm.htm[/URL] and [url]http://www.sci.fi/~benefon/azimalt.cpp[/url] but i'm still not sure how to get pitch, roll and yaw using this code.
Standard output stream obviously, because that isn't an error.
What's the best way to handle JSON url changes? Right now I have a Connection class I use to start a connection to a URL. Only thing is the URL changes sometimes. It always starts with [url]http://api.themoviedb.org/3/[/url] If I want to search a movie title I need: [url]http://api.themoviedb.org/3/search/movie/API_KEY&query=movieName[/url] But if I want to search by ID it's like: [url]http://api.themoviedb.org/3/movie/MOVIEID?API_KEY[/url] So is the only way to really do it by having different endings past the /3/ that I can add to the end of the base URL?
Basically, yes. Of course, you can encapsulate that in methods of your class, so you can just call api.movieById() or api.movieByTitle() or something like that. Besides, someone's probably already written a wrapper for themoviedb for whatever language you're using.
Sweet just making sure the way I was doing it isn't too terrible. I know there are wrappers, but thought I would try write some myself for use in a project, just to practice mainly for a coding test for a job I have tomorrow
I am not sure if this is also the "What you need help with" thread for Web stuff, since the forums merged either some threads are not reopened or merged into others. I got a div that uses flex box, so everything in it is nicely centered. Now for some reason all elements show up in Chrome and IE, but not in Firefox. How it should look like: [img]http://i.imgur.com/8mIFyuo.png[/img] How it actually looks [img]http://i.imgur.com/CYNkYMV.png[/img] What I noticed is, in Firefox the img element gets a random class assigned and cannot load the png file. Firefox snippet, from inspect element [code] <div id="twitter" class="navelem" style="margin-top: 50px;"> <a href="https://twitter.com/----"> <img class="ymkrrnablfonepqieafm" src="img/twitter-icon.png"> </img> <span></span> </a> </div> [/code] While in the HTML file it looks like this: [code] <div id="twitter" class="navelem" style="display: none;"> <a href="https://twitter.com/----"> <img src="img/twitter-icon.png" /> <span>Twitter</span> </a> </div> [/code] Display none is for jquery .fadeIn(). This will be applied to every element with the navelem class. The container the elemts are in has this css: [code] .nav { margin-top: 0px; margin-left: auto; margin-right: auto; display: flex; flex-direction: row; justify-content: center; width: 100%; height: 100%; } [/code] Is there a way to make it show up in Firefox? A live version can be viewed here: [url]https://dl.dropboxusercontent.com/u/17442600/diwako/index.html[/url]
How do I decompose XYZ ordered rotation matrix back to euler angles?
[QUOTE=diwako;46946041]-snip- Is there a way to make it show up in Firefox? A live version can be viewed here: [url]https://dl.dropboxusercontent.com/u/17442600/diwako/index.html[/url][/QUOTE] While I don't know about your issue, I can report that that page works fine for me in Firefox (35). Maybe it's an add-on that's causing your issue?
That is weird, but good to know it is working. Just tested it without any add-on enabled, it works now. Thanks for pointing that out. I can now finally move the page on a domain.
If anyone is familiar with the Gamebryo .ESM format used in Fallout 3 and New Vegas, I'm trying to read cell data and would appreciate help from anyone that is interested. If you have any info about the format or would like to help reverse engineer it please let me know, thanks!
So, I'm not really expecting much, but I'll ask anyways. With Rant, does anyone know if it's possible to store the result of a [url=https://github.com/TheBerkin/Rant/wiki/Subroutines]subroutine[/url], a la [url=https://github.com/TheBerkin/Rant/wiki/Query-macros]query macros[/url]? Let's say I have a subroutine like this: [code][$[phone]:+[num:1;200]-([num:100;999])-[num:100;999]-[num:1000;9999]] [/code] If I then call this query, in something like this: [code]<name>'s phone-number is [$phone].[/code] It generates a number of the format +x-(xxx)-xxx-xxxx. However, I cannot store this like I could a normal macro. [code]<@person=name::constantperson> // Allows me to call <@person> to consistently refer to the same name. <@personphone=[$phone]::constantphone> // Errors; I want to be able to call something like <@phone> and consistently refer to the same phone pattern.[/code] Does anyone know if this is possible, and if so, how?
Incase anyone has Firefox extension experience. [code] if (res != nsIFilePicker.returnCancel){ var thefile = fp.file; if (!fp.file.leafName.endsWith('.m3u8') && !fp.file.leafName.endsWith('.m3u')) thefile.file.leafName += '.m3u8'; var stringToWrite = playlist.join('\r\n'); OS.File.writeAtomic(thefile,stringToWrite,{encoding:'utf-8'}).then( function(aVal) { console.log('new file made') console.log(thefile.path) }, function(aReason) { console.warn('failed to right, aReason:', aReason); } ); }[/code] Is my file picking code. I want to automatically add .m3u8 to the end of the file extension but I have no idea how to do it.
[QUOTE=Gmod4ever;46949254]So, I'm not really expecting much, but I'll ask anyways. With Rant, does anyone know if it's possible to store the result of a [url=https://github.com/TheBerkin/Rant/wiki/Subroutines]subroutine[/url], a la [url=https://github.com/TheBerkin/Rant/wiki/Query-macros]query macros[/url]? Let's say I have a subroutine like this: [code][$[phone]:+[num:1;200]-([num:100;999])-[num:100;999]-[num:1000;9999]] [/code] If I then call this query, in something like this: [code]<name>'s phone-number is [$phone].[/code] It generates a number of the format +x-(xxx)-xxx-xxxx. However, I cannot store this like I could a normal macro. [code]<@person=name::constantperson> // Allows me to call <@person> to consistently refer to the same name. <@personphone=[$phone]::constantphone> // Errors; I want to be able to call something like <@phone> and consistently refer to the same phone pattern.[/code] Does anyone know if this is possible, and if so, how?[/QUOTE] Oh, hey, that's my department. You could use the [branch] and [merge] functions to synchronize the RNG: [code] [$[phone:name]: [branch: [arg:name]] +[num:1;200]-([num:100;999])-[num:100;999]-[num:1000;9999] [merge] ] [$phone: person1] [$phone: person2] [/code] Once midterms are over and I have time to dig into Rant, all the different variable types will be unified (carriers, arithmetic variables, subroutines, etc) and a string type will be added, so you could do something like: [code] `a=[$phone]` `a` [/code]
[QUOTE=Itsamario;46953693]Incase anyone has Firefox extension experience. [code] if (res != nsIFilePicker.returnCancel){ var thefile = fp.file; if (!fp.file.leafName.endsWith('.m3u8') && !fp.file.leafName.endsWith('.m3u')) thefile.file.leafName += '.m3u8'; var stringToWrite = playlist.join('\r\n'); OS.File.writeAtomic(thefile,stringToWrite,{encoding:'utf-8'}).then( function(aVal) { console.log('new file made') console.log(thefile.path) }, function(aReason) { console.warn('failed to right, aReason:', aReason); } ); }[/code] Is my file picking code. I want to automatically add .m3u8 to the end of the file extension but I have no idea how to do it.[/QUOTE] [code] var thefile = fp.file; if (!thefile.leafName.endsWith('.m3u8') && !thefile.leafName.endsWith('.m3u')) thefile.leafName += '.m3u8'; [/code] Try that
[QUOTE=Hattiwatti;46946193]How do I decompose XYZ ordered rotation matrix back to euler angles?[/QUOTE] Is this even possible to do precisely? I've tried writing a few functions and google'd a few, but they're always either completely wrong or they have some small offsets.
[QUOTE=cody8295;46954130][code] var thefile = fp.file; if (!thefile.leafName.endsWith('.m3u8') && !thefile.leafName.endsWith('.m3u')) thefile.leafName += '.m3u8'; [/code] Try that[/QUOTE] Nope, entirely breaks it. Edit: [code] if (!fp.file.leafName.endsWith('.m3u8') && !fp.file.leafName.endsWith('.m3u')) thefile.leafName += '.m3u8'; [/code] Does work though. Thanks!
[code]instruction.text = player.GetType ().GetField (variable).GetValue (variable).ToString ();[/code] Trying to add some [i]reflection[/i] in my game. I want to create a script which I can put on different text-objects and just specify as a string what variable I want from Player. I don't want to create 50 different scripts just because I want 50 different variables. In the above code I'm trying to get 'variable' which is a string, the name of a variable I want to get. I can get to the variable just fine but I don't know how to pull the data out of the variable. I'm getting the following error: [code] ArgumentException: Field 'level' defined on type 'Entity' is not a field on the target object which is of type 'String'[/code] I'm not sure if it's because Player inherits from 'Entity' or what. I'm writing this in Unit, so I can see that it's getting the instance of the 1 player object. [editline]17th January 2015[/editline] I figured it out, I just had to pass 'player' to getValue instead of 'variable'. oh wow
Guys, how the fuck do I get motivated?
[QUOTE=itsthejayden;46955046]Guys, how the fuck do I get motivated?[/QUOTE] What do you want to achieve?
[QUOTE=JohanGS;46955197]What do you want to achieve?[/QUOTE] Basically anything, I personally want to get better at coding, but it could apply to anything.
[QUOTE=itsthejayden;46955514]Basically anything, I personally want to get better at coding, but it could apply to anything.[/QUOTE] what do you like i like games so I'm making a game
Sorry, you need to Log In to post a reply to this thread.