• What do you need help with? Version 5
    5,752 replies, posted
What is Python? Last time I was here, I was told that C# is probably the best language to start with and I did, I made a very basic password thing which was pretty neat, but then my hard drive died and I lost all of that stuff so I decided not to do it anymore. Now my interest in it is being redeemed, except I come here to the threads about people choosing programming languages for the first time and everyone is making a huge fuss about Python, whatever that is. I could probably google it, but FPers are better at putting things into layman terms. So what is it? What is the difference between it an C#
C# is statically-typed and compiles to byte code and is compiled JIT at run-time (I think... C# guys can correct me if I've got this wrong). It's a lot like Java in many regards. It's primarily OOP and uses "C-like" syntax. This does not imply that the language itself is anything like C or C++, however. It just [i]looks[/i] a little bit like C, superficially. Python is an interpreted, duck-typed language. It's guided by some really strong design philosophies ('batteries included' and 'one obvious way'), meaning that the language should have everything you could ever ask for included in the standard library and that 'pythonic' (or idiomatic) code should have one obvious way to express any given process. It's sort of mixed-paradigm in the sense that you have all the usual OOP tools, but it's not uncommon to see a lot of procedural code in Python scripts. Python is great for prototyping and rapid development, solving one-time problems, etc., but it's not limited to this niche. Statically-typed means that variable types are determined at compile time, and the compiler will yell at you if an operation is performed on a type which it does not expect. Duck-typing is where the interpreter, compiler, or whatever determines if the operation can be performed by looking at the methods of the object, rather than at its actual type ('if it looks like a duck and it quacks like a duck, then it's a duck')
Does anyone know if there's some form of matching brace highlighting in XCode? As in if I click on a curly bracket at the beginning of a for loop it'll show me the matching curly bracket that closes it? I can't find it anywhere. EDIT: Nevermind, if you double-click on a bracket it'll highlight the code wrapped in it.
Can anyone point me to some good pathfinding theory I can utilise in my isometric game?
[QUOTE=_NewBee;35669667]Can anyone point me to some good pathfinding theory I can utilise in my isometric game?[/QUOTE] I believe A* will be the easiest and most efficient in such a game.
[QUOTE=_NewBee;35669667]Can anyone point me to some good pathfinding theory I can utilise in my isometric game?[/QUOTE] do you have weighted edges or not?
[QUOTE=swift and shift;35669969]do you have weighted edges or not?[/QUOTE] I do
Okay, so I'm currently experimenting with sprite masking and pixel-perfect collisions in SFML: [video=youtube;d4JsKGq59I4]http://www.youtube.com/watch?v=d4JsKGq59I4&hd=1[/video] Each object has a bitfield that describes where it can collide and where not. To check collisions between the ship and the map, I iterate over the bitfield, take each 1's local coordinates, apply the ship's transformation to it (since it inherits from sf::Transformable) and check the resulting coordinates in the map's collision bitfield. To create the particle effect when I shoot the building, I have a pre-generated 2D array of particles, where each particle represents a pixel of the building (with it's color). When the building is hit, I "activate" the particles within a certain radius and apply physics to them. They collide with the bitfield described above. Now, to have the same effect on the ship, I would need to move the "activated" particles from ship-coordinates to world-coordinates, again by applying the transformation I get from the ship. This results in both features (I implement them in base classes Collidable and Destructable) requiring the transformation info, and thus inheriting from sf::Transformable. But then I have to combine them for my ship, inheriting from Collidable and Destructable and NOW I encounter diamond inheritance, which I really want to avoid. What should I do? Is there some kind of design pattern where certain aspects need the same info but can later be combined?
I'm using [b]FreeType 2[/b], and I am drawing every character based on their ascii-code. I am looping from 32 to 255, but all the characters beyond 126 are rendered as squares. How can I make freetype display these? Is this a known issue or have I dun goofed up?
[QUOTE=Mordi;35671283]I'm using [b]FreeType 2[/b], and I am drawing every character based on their ascii-code. I am looping from 32 to 255, but all the characters beyond 126 are rendered as squares. How can I make freetype display these? Is this a known issue or have I dun goofed up?[/QUOTE] Are you sure the font you are using has those characters?
[QUOTE=Mordi;35671283]I'm using [b]FreeType 2[/b], and I am drawing every character based on their ascii-code. I am looping from 32 to 255, but all the characters beyond 126 are rendered as squares. How can I make freetype display these? Is this a known issue or have I dun goofed up?[/QUOTE] Most likely the font doesn't have those characters. It's up to the font designers to include characters, not freetype. But also make sure you're calling FT_Load_Glyph(FT_Get_Char_Index(char), ...) to load the proper glyph index.
[QUOTE=Z_guy;35671401]Are you sure the font you are using has those characters?[/QUOTE] Yes, I'm quite sure. [url]http://www.dafont.com/harabara.font[/url] However, I'm not sure whether or not it uses a unicode character-map. I guess I should try more standard fonts. Otherwise, I have no clue. Edit: I tested with Arial.tff, and it still rendered all the non-standard characters as squares. Edit2: Hmm, it seems I need to use wide characters to get more than the standard set. Not sure how to do that. I'll give it a go.
Does anyone have any experience with this type of sigfault? [quote]Program received signal SIGSEGV, Segmentation fault. 0x0804d38a in glm::detail::tvec4<float>::tvec4 (this=0xbfffea90, v=...) at ../extLib/include/glm/./core/type_vec4.inl:89 89 w(v.w) [/quote] I get it 2 out of 3 times I run my program
[QUOTE=ROBO_DONUT;35664141]C# is statically-typed and compiles to byte code and is compiled JIT at run-time (I think... C# guys can correct me if I've got this wrong). It's a lot like Java in many regards. It's primarily OOP and uses "C-like" syntax. This does not imply that the language itself is anything like C or C++, however. It just [i]looks[/i] a little bit like C, superficially. Python is an interpreted, duck-typed language. It's guided by some really strong design philosophies ('batteries included' and 'one obvious way'), meaning that the language should have everything you could ever ask for included in the standard library and that 'pythonic' (or idiomatic) code should have one obvious way to express any given process. It's sort of mixed-paradigm in the sense that you have all the usual OOP tools, but it's not uncommon to see a lot of procedural code in Python scripts. Python is great for prototyping and rapid development, solving one-time problems, etc., but it's not limited to this niche. Statically-typed means that variable types are determined at compile time, and the compiler will yell at you if an operation is performed on a type which it does not expect. Duck-typing is where the interpreter, compiler, or whatever determines if the operation can be performed by looking at the methods of the object, rather than at its actual type ('if it looks like a duck and it quacks like a duck, then it's a duck')[/QUOTE] I'm just looking for a versatile language to learn that I can use to make all sorts of different simple things as I learn, but eventually progress to a point in my learning when I will be able to create games and things like I see other members doing in the What are you working on thread.
"Versatile" describes Python perfectly.
Anybody want to help me program Snakes & Ladders in C++? Need to do it for an assignment and in command window. Any help would be great.
[QUOTE=ROBO_DONUT;35674971]"Versatile" describes Python perfectly.[/QUOTE] Is Python a popular, well used language though? I was thinking something more along the lines of C# or C++ but I'm still uncertain
[QUOTE=zzzz;35676365]Is Python a popular, well used language though[/QUOTE] On par if not more used than Lua and Perl, probably more popular than Ruby. [editline]23rd April 2012[/editline] Did I just say Lua and Perl are similarly popular what is my mind doing
I've narrowed my problem down. Maybe someone can help now. I think it's more of a general c++ issue, than a FreeType specific problem. The problem lies here: [cpp]FT_UInt glyphIndex = FT_Get_Char_Index(face, str[i]);[/cpp] glyphIndex will give me only "0" (which is the code for the font's EM square) if str[i] is a foreign character. Question is, what would it accept as a valid value? Edit: [IMG]http://i.snag.gy/f1y6u.jpg[/IMG] Here I have used the console to print some values. "Str" is the string that I give the Get_Char function (see above). "Int" is the same as Str, only typecast into an unsigned integer. As you can see, after it hits character value 126, it seems to go negative, as if it were looping around the limits of an integer. I'm not sure how to handle this. I guess what I need to do is stop using std::string and start using unsigned characters to get the full 255-character scheme. Edit: [cpp]FT_UInt glyphIndex = FT_Get_Char_Index(face, (unsigned char)str[i]);[/cpp] This seems to work, although the font seems to mapped differently than the actual character-set that c++ uses. A short row of the glyphs are missing. Edit: Consider this solved.
[QUOTE=zzzz;35676365]Is Python a popular, well used language though?[/QUOTE] Yes? The very first Bittorrent client was written in Python.
Should I change my game from using a list to a map? I have a list of players, which will rarely change so I am thinking it'll be good to change that to a map(as each player has a distinct ID). I also have a list of projectiles which change pretty often but will be checked much more often then they are changed (a change per tick but a check against all of them a tick as well). I heard that list insertion is fast but lookup takes O(n) time, while maps use O(log(n)) time for insertion and look up. I am unsure how to interpret that, and after looking at some graphs it seems log(n) is slower at first but breaks in the long run depending on the amount of elements. Which one should I use, and what is the break point?
What is a good book I can buy or a website to go to to get started using Visual Studio to create things with C#?
I keep getting this error: :0|1|error: macro names must be identifiers| Yet I have managed to narrow my code down so much that its just: [cpp] int main() { return 0; }[/cpp] and I still get the error
So I just learned python thanks to google but now I have no idea how to improve on it. What are some things that you guys recommend me on learning. so far I made this [url]https://gist.github.com/2e11c0c1d9586951f365[/url] it was pretty easy and thanks for help by a fp'er that helped me figure out how to use os.walk
[QUOTE=Mordi;35676734]I guess what I need to do is stop using std::string and start using unsigned characters to get the full 255-character scheme. Edit: [cpp]FT_UInt glyphIndex = FT_Get_Char_Index(face, (unsigned char)str[i]);[/cpp] This seems to work, although the font seems to mapped differently than the actual character-set that c++ uses. A short row of the glyphs are missing. Edit: Consider this solved.[/QUOTE] FreeType works with Unicode (unsigned ints). For some really rare characters, you'll have trouble even with unsigned chars. Just a heads up. If you want to load all of the glyphs in a font, you can use a combination of FT_Get_First_Char and FT_Get_Next_Char like in the example here: [url]http://freetype.sourceforge.net/freetype2/docs/reference/ft2-base_interface.html#FT_Get_First_Char[/url]
I made probably one of the easiest script in C, but it keeps crashing. Can I get some help please? [code]#include <stdio.h> #include <stdlib.h> int main(){ int number = 0; printf("Number "); scanf("%d", number); int answer = number * number; printf("Answer %d", answer); return 0; }[/code]
you want to give scanf a pointer to 'number'
[QUOTE=swift and shift;35681264]you want to give scanf a pointer to 'number'[/QUOTE] Just realised I forgot & before number, what a dumbass -_-
[QUOTE=bilbasio;35681324]Just realised I forgot & before number, what a dumbass -_-[/QUOTE] in future, compile with -Wall -Wextra -Werror -pedantic [editline]23rd April 2012[/editline] The -Werror forces you to fix all warnings before compiling successfully. You really should do that
How can I make my project net-friendly? I don't want to add networking yet, but I want it to be possible later down the line.
Sorry, you need to Log In to post a reply to this thread.