• What are you working on? V10
    2,002 replies, posted
[QUOTE=midlet_guy;21879509]Ok so i got a bit into SFML .And right now i want to display an image(Gwen logo :v: ) the image is loaded but it isn't display.Whats wrong with my code ? BTW im a C++ n00bbut learning though [code] #include <SFML/Graphics.hpp> //Initializer int main() { //Sitas daiktas sukur pagr langa sf::RenderWindow App(sf::VideoMode(800,600,32), "SFML Testas"); //foto sf::Image gwen; if (!gwen.LoadFromFile("gwen.png")) return EXIT_FAILURE; //sukuriam spraita sf::Sprite Spraitas(gwen); Spraitas.SetPosition(200.f, 100.f); Spraitas.SetScale(2.f, 2.f); Spraitas.SetCenter(0, 0); //Loopas while (App.IsOpened()) { // Procesuoti eventus sf::Event Eventas; while (App.GetEvent(Eventas)) { // Uzdaryti langa if (Eventas.Type == sf::Event::Closed) App.Close(); } // Get elapsed time float ElapsedTime = App.GetFrameTime(); // Isvalyti ekrana App.Clear(); // Parodyti ka turime App.Display(); // Parodyti foto App.Draw(Spraitas); //Screenshoto funkcija(IS TUTORO) if (Eventas.Key.Code == sf::Key::F1) { sf::Image Screen = App.Capture(); Screen.SaveToFile("screenshot.jpg"); } } return EXIT_SUCCESS; }[/code][/QUOTE] Try putting the Draw call before the Display call.
I've hacked together a rudimentary gui system for SFML. It has one widget: an Image Button, but the code is quite clean, if hugely suboptimal. It's for use in my gravity simulation thingy. [editline]08:04PM[/editline] Oh, I've christened it "Stiki". See if you can spot the awful pun :P
Hey, how do you people make a console in game that takes commands? Do you go through a case statement that checks the users entered text against every available command? I imagine it would be inefficient but I can't see any other way.
[QUOTE=nos217;21880577]Hey, how do you people make a console in game that takes commands? Do you go through a case statement that checks the users entered text against every available command? I imagine it would be inefficient but I can't see any other way.[/QUOTE] You can use a hash table (hash map) with string keys and function/delegate/functor values. What programming language are you using?
Thanks a lot, I'm using C++. I can't put too much effort into this right now, as I have Higher exams (Scottish ones) starting tomorrow, but I just thought of this and decided to ask. I've never used or revised Hash Tables, and I looked it up on Wikipedia and that didn't help. Looks like Wikipedia over-complicated it.
[QUOTE=efeX;21880302]Try putting the Draw call before the Display call.[/QUOTE] Thanks it work.Silly me :D
[QUOTE=nos217;21880819]Thanks a lot, I'm using C++. I can't put too much effort into this right now, as I have Higher exams (Scottish ones) starting tomorrow, but I just thought of this and decided to ask. I've never used or revised Hash Tables, and I looked it up on Wikipedia and that didn't help. Looks like Wikipedia over-complicated it.[/QUOTE] If you're using a compiler with support for the TR1 extension, you can use the class std::tr1::unordered_map from the header tr1/unordered_map. External libraries can also contain implementations of TR1, like boost::tr1. Using it is easy, the interface is much like std::map, but random lookup time will be very close to O(1).
[IMG]http://anyhub.net/file/loltiles.png[/IMG] The XNA tiling system for the platformer I'm working on, with humorous message. As you can see, there's a little guy in the corner. He will be the player and his position is decided by a specific tile code. Tiles are held in a separate file and look kinda like this: 1,1,1,1 0,0,0,0 1,0,2,0 The tile 1 may be a grass tile, the 0 would be transparent and the 2 may be dirt. I know it probably isn't much to most of you guys, but this is my first time using XNA and I feel as though I've achieved :D I'm having a small problem in that my collision detection isn't working. I do it by defining a rectangle that's the size of my player and is at the same position. I check in the draw void if it and the bounding rectangle for each of my tiles is colliding. If they are, it's supposed to turn the background red. However, that doesn't work. Anyone got any better ways or doing this?
I've been learning XNA with C#, made a quick basic 2D minecraft thing (very original) [img]http://i43.tinypic.com/2mk8x.png[/img]
Today I had some time left over during my Computer Networking class, so I took my gradebook application and included classes. Reading and writing to my file is now handled by a class. [cpp] int main() {//1 using namespace std; fstream ClientFile("grades.tst", ios::in | ios::out | ios::app ); fstream DBFile( "IDatabase.tst", ios::in | ios::out | ios::app ); ofstream ODBFile( "IDatabase.tst", ios::app ); if( !ClientFile ) {//2 MessageBox( NULL, L"Grade.tst not found or could not be read!", NULL, NULL); fstream ClientFile( "grades.tst", ios::in | ios::app | ios::binary ); ::Sleep( 1000 ); cerr << "File Created!"; }//3 if( !DBFile ) { //4 MessageBox( NULL, L"IDatabase.tst not found or could not be read!", NULL, NULL); fstream DBFile( "IDatabase.tst", ios::in | ios::app | ios::binary ); ::Sleep( 1000 ); cerr << "File Created!"; } //5 int INPUT; int IDNum; string id; string firstname; string lastname; string stuffName; string line; cout << "Welcome to the Gradebook system designed by Kyle Devine, menu sortings are below." << endl << "1 - Grades" << endl << "2 - Instructions" << endl << "3 - Quit" << endl << "Just enter the number of the menu you want to enter" << endl; cin >> INPUT; if(INPUT == 1) // Enter to the grade list, which than displays ID, name, than their grade in percent. Shows a wierd ass thing though { system("cls"); cout << "Welcome to the grade list, please wait while the ID file is loaded, to add a person, type their ID followed by their first name, then last name, then their" << endl << "grade." << endl; //Creating a table for the list which is pulled from the file. cout << left << setw( 10 ) << "ID Number" << setw( 13 ) << "Last Name" << setw( 13 ) << "Grade" << endl << fixed; //Pull the data from the ID database and than list it DBFile >> IDNum; DisplayStuff display; display.fileread(); display.filewrite(); } } [/cpp] And the header file with the classes [cpp] #ifndef GRADEBOOK_H #define GRADEBOOK_H #include <iostream> #include <string> #include "windows.h" using namespace std; class DisplayStuff { public: void fileread() { ifstream DBFile( "IDatabase.tst", ios::in ); while( getline( DBFile , line )) { cout << line << endl; } } void filewrite() { ofstream ODBFile( "IDatabase.tst", ios::app ); while( cin >> IDNum >> firstname >> lastname >> grade ) { if( !ODBFile ) { MessageBox( NULL, L"Failure to open file for output!", L"PROBLEM OH GOD PROBLEM!", NULL ); } ODBFile << IDNum << " " << firstname << " " << lastname << " " << grade << endl; } } private: string line; int IDNum; string className; string firstname; string lastname; double grade; string stuffName; }; #endif [/cpp] This is a big deal for me as its my first time using classes in something I've written myself.
[QUOTE=Dlaor;21861604]Shit, I'm getting addicted to my own game :v: [img_thumb]http://www.cubeupload.com/files/291200mclone4.png[/img_thumb] (disabled grass at the moment, I messed it up again) [editline]10:48PM[/editline] Ok guys, I need some help. I have no clue how to make platformer physics for the player entity. Anyone wanna guide me in the right direction? I know how to do collisions (just go through every block, and if it intersects the player boundary box, collision has occured) but I don't know how to do the platformer velocity stuff...[/QUOTE] Progress... [img]http://dl.dropbox.com/u/4081391/failcol_1.gif[/img] As you can see, I (the red block) just passed right through the building. How would I stop this from happening? Collisions work fine only when I'm moving very slowly.
All these minecraft clones look suspiciously like sidescroller map editors. :ninja:
I would do this by getting the speed vector and then testing if that line intersects with the blocks.
[QUOTE=nos217;21880577]Hey, how do you people make a console in game that takes commands? Do you go through a case statement that checks the users entered text against every available command? I imagine it would be inefficient but I can't see any other way.[/QUOTE] I have a pretty decent console going. For simple one-word commands I just do something like: AddConsoleCommand("cls|clear", Clear); where there's a function called Clear(), which can be called by entering 'clear' or 'cls'. For console commands that have arguments I tokenise them (by the space character) into string arrays and do switch(string[0]), then deal with each possibility separately.
[QUOTE=Robert64;21881704]I've been learning XNA with C#, made a quick basic 2D minecraft thing (very original) [img]http://i43.tinypic.com/2mk8x.png[/img][/QUOTE] Can you add me on Steam and send me those sprites you're using?
[url]http://www.metanetsoftware.com/technique/diagrams/tutA_demo.html[/url] This is basically what I want for my game... :v:
[QUOTE=Dlaor;21881849]Progress... [img]http://dl.dropbox.com/u/4081391/failcol_1.gif[/img] As you can see, I (the red block) just passed right through the building. How would I stop this from happening? Collisions work fine only when I'm moving very slowly.[/QUOTE] If you want the easy way out, just make it so you can't move more than one square per frame. [editline]04:25PM[/editline] It looks like 2D minecraft clones are the new mandelbrot :v:
[QUOTE=SamPerson123;21882641]It looks like 2D minecraft clones are the new mandelbrot :v:[/QUOTE] And the new graph drawers
[QUOTE=NovembrDobby;21882140]I have a pretty decent console going. For simple one-word commands I just do something like: AddConsoleCommand("cls|clear", Clear); where there's a function called Clear(), which can be called by entering 'clear' or 'cls'. For console commands that have arguments I tokenise them (by the space character) into string arrays and do switch(string[0]), then deal with each possibility separately.[/QUOTE] Ah very clever. Thanks.
[QUOTE=Dlaor;21882637][url]http://www.metanetsoftware.com/technique/diagrams/tutA_demo.html[/url] This is basically what I want for my game... :v:[/QUOTE] Try casting a ray from their start position to where they'd end up, and seeing if it passes through any grid spaces that have a colliding tile.
[QUOTE=Shanethe13;21883415]Try casting a ray from their start position to where they'd end up, and seeing if it passes through any grid spaces that have a colliding tile.[/QUOTE] This, and if travelling one more frame at the current speed causes you to pass through or hit an object, make your current location equal to the position of the colliding object + it's width.
[QUOTE=Cookies114;21873640][IMG]http://thecyl.com/somethingtosay.PNG[/IMG][/QUOTE] Yeah, I saved it in paint.NET, got a problem with that?
He is trying to imply that you made in Paint.NET With that level of what I can only describe as agresssive pedantry, I can only assume he has problems integrating with normal society.
[QUOTE=Technopath;21873935]Newsflash, it looks ugly for game screenshots so people remove it.[/QUOTE] Mine starts in full screen. [editline]08:57PM[/editline] [QUOTE=TheBoff;21883607]He is trying to imply that you made in Paint.NET With that level of what I can only describe as agresssive pedantry, I can only assume he has problems integrating with normal society.[/QUOTE] I know, that's why I think he is a classical 'Jackass'.
I played Minecraft in my computer science class for three days, I'm still miles ahead of everyone else and retaining my 100% grade in that class. I'm going to start bringing my XNA and my netbook to class now :)
[QUOTE=Ortzinator;21881995]All these minecraft clones look suspiciously like sidescroller map editors. :ninja:[/QUOTE] :ssh:
[QUOTE=Dlaor;21882637][url]http://www.metanetsoftware.com/technique/diagrams/tutA_demo.html[/url] This is basically what I want for my game... :v:[/QUOTE] sweet!
So let's say I'm moving from C# to C++, what books/sites/tips/kittens/GameMakers do you guys recommend me so I can master c++ and make my dream MMORPGFPSRTS-Racing-adventure-game ?
[QUOTE=Xerios3;21887289]So let's say I'm moving from C# to C++, what books/sites/tips/kittens/GameMakers do you guys recommend me so I can master c++ and make my dream MMORPGFPSRTS-Racing-adventure-game ?[/QUOTE] I've always found this be a good start: [url]http://www.cplusplus.com/doc/tutorial/[/url] Shouldn't be too difficult to pick up seeing as you know C#.
[QUOTE=Xerios3;21887289]So let's say I'm moving from C# to C++, what books/sites/tips/kittens/GameMakers do you guys recommend me so I can master c++ and make my dream MMORPGFPSRTS-Racing-adventure-game ?[/QUOTE] accelerated c++ is going to be recommended a lot
Sorry, you need to Log In to post a reply to this thread.