• What are you working on? v15
    5,001 replies, posted
[QUOTE=Loli;27936246]Is that a guitar on your ceiling?[/QUOTE] Eeeerrmmmmmm 'course not! :ninja:
I want to play an animation at my map every some seconds, does anyone know how to do that with SFML? I have a graphic already, the problem lies in animating it and having it appear. [img]http://dl.dropbox.com/u/2670708/even%20more%20folders/progarmming/cirkel2.png[/img]
[QUOTE=Dryvnt;27936685]I want to play an animation at my map every some seconds, does anyone know how to do that with SFML? I have a graphic already, the problem lies in animating it and having it appear. [img_thumb]http://dl.dropbox.com/u/2670708/even%20more%20folders/progarmming/cirkel2.png[/img_thumb][/QUOTE] Just have the sf::Sprite's sf::Image change to the next frame in your update loop.
[QUOTE=Dryvnt;27936685]I want to play an animation at my map every some seconds, does anyone know how to do that with SFML? I have a graphic already, the problem lies in animating it and having it appear. [img_thumb]http://dl.dropbox.com/u/2670708/even%20more%20folders/progarmming/cirkel2.png[/img_thumb][/QUOTE] I can share my sprite animation code with you if you want. It might be a little over-complicated though because it doesn't just do calculations for different frames, but also calculates different animations (i.e walking, running, jumping) based on the row you've selected.
[QUOTE=Kopimi;27936746]I can share my sprite animation code with you if you want. It might be a little over-complicated though because it doesn't just do calculations for different frames, but also calculates different animations (i.e walking, running, jumping) based on the row you've selected.[/QUOTE] It can't hurt. I might even learn something :buddy:
It's not really what I'M working on but a friend of mine is devloping a program right now simply called the "Java Game Maker". It uses a drag n drop interface similar to Game Maker but JGM games can be converted to be played in a Java applet through a browser. It's really early in the works but I'll post what it is so far if anyone's interested?
[QUOTE=AaRoNg11;27936197][CODE] TerrainGen.cs return (1.0d - ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0d); [/CODE] So many magic numbers :p[/QUOTE] RNG's pretty much always have magic numbers/primes.
[QUOTE=TheBoff;27932727]and that's because he's an arse and the thread is better off without him.![/QUOTE] wrong.
[QUOTE=AaRoNg11;27936197][CODE] TerrainGen.cs return (1.0d - ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0d); [/CODE] So many magic numbers :p[/QUOTE] The magic numbers are actually fairly carefully selected to ensure that the function doesnt repeat too often, and produces unique outputs [url]http://en.wikipedia.org/wiki/Linear_congruential_generator[/url]
[QUOTE=bootv2;27936830]just do a loop and use ElapsedTime to calculate the amount of time that's passed, if enough time is passed us setsubrect to set the next animation frame. do this untill your animation is ended.[/QUOTE] I'm sorry, I just can't figure out how to make it work. I hope you wouldn't mind finding some snippets or something I can use?
[QUOTE=Icedshot;27937370]The magic numbers are actually fairly carefully selected to ensure that the function doesnt repeat too often, and produces unique outputs [url]http://en.wikipedia.org/wiki/Linear_congruential_generator[/url][/QUOTE] I thought that you could just use pretty much any big prime numbers.
I'm unsure on how to handle 2D platform movement in my game, anyone have any suggestions/articles on it? ex. Move the character x pixels down every frame unless it hits an object.
[QUOTE=deloc;27937186]wrong.[/QUOTE] Not something you can judge. You have a somewhat biased opinion, I think.
[QUOTE=neos300;27937648]I'm unsure on how to handle 2D platform movement in my game, anyone have any suggestions/articles on it? ex. Move the character x pixels down every frame unless it hits an object.[/QUOTE] and when it hits an object, scan up Y pixels, and if theres an open space move the character, otherwise move him back Thats pretty much how collision detection works in my game
[url]http://stevenbenner.com/2010/07/the-5-types-of-programmers/[/url] Where do you guys fit in? I'm almost definitely the duct tape one :buddy:
[QUOTE=Jallen;27938511][url]http://stevenbenner.com/2010/07/the-5-types-of-programmers/[/url] Where do you guys fit in? I'm almost definitely the duct tape one :buddy:[/QUOTE] Yeah I'm very much Duct-Tape I prefer to be just dumped a problem then left to my own devices to solve it. [editline]8th February 2011[/editline] Also, today I was pulling assessment aspects (an aspect is a "type" of assessment criteria like a target, a grade, etc.) out of a database and realised I was doing an additional SQL query in the Aspect class for each aspect to lookup its name and if its enabled or not. There's about 20-30 aspects on a typical page so when I'd fixed it the page loading time went from about 8 seconds down to less than half a second. Boy did I feel silly.
[QUOTE=Jallen;27938511][url]http://stevenbenner.com/2010/07/the-5-types-of-programmers/[/url] Where do you guys fit in? I'm almost definitely the duct tape one :buddy:[/QUOTE] The theoretical programmer is the very definition of me. I mean, I thought they were reading my mind at the staring blankly at the screen part :v: When I eventually [B]do[/B] something, I guess I'm more of a OCD perfectionist. I'd rather not have others touch my pretty sources :h: (No, I'm serious. Usually when I go "Lol I shall program" I end up writing nothing for the whole day)
Could someone please try to explain the Miller-Rabin test to me in plain words? I looked at the wiki but just got depressed.
[QUOTE=Darwin226;27938702]Could someone please try to explain the Miller-Rabin test to me in plain words? I looked at the wiki but just got depressed.[/QUOTE] There's even a pseudocode implementation in there [code] Input: n > 3, an odd integer to be tested for primality; Input: k, a parameter that determines the accuracy of the test Output: composite if n is composite, otherwise probably prime write n − 1 as 2s·d with d odd by factoring powers of 2 from n − 1 LOOP: repeat k times: pick a random integer a in the range [2, n − 2] x ← ad mod n if x = 1 or x = n − 1 then do next LOOP for r = 1 .. s − 1 x ← x2 mod n if x = 1 then return composite if x = n − 1 then do next LOOP return composite return probably prime [/code] [editline]8th February 2011[/editline] I mean that's probably the easiest way to explain it
[QUOTE=Jallen;27938511][url]http://stevenbenner.com/2010/07/the-5-types-of-programmers/[/url] Where do you guys fit in? I'm almost definitely the duct tape one :buddy:[/QUOTE] Duck-tape is kinda me but then [quote]He will spend 80% of his time staring blankly at his computer thinking up ways to accomplish a task[/quote] Is definitely me
[QUOTE=Jallen;27938511][url]http://stevenbenner.com/2010/07/the-5-types-of-programmers/[/url] Where do you guys fit in? I'm almost definitely the duct tape one :buddy:[/QUOTE] I feel I'm the theoretical programmer, altough if I'm on a tight deadline I'm duct tape :v:
I guess I'm a duct-tape-perfectionist-OCD programmer with some theoretical mumbo-jumbo thrown in for good measure
Bam! [IMG]http://i56.tinypic.com/1zfoa4h.jpg[/IMG]
[QUOTE=Richy19;27938772]Duck-tape is kinda me but then Is definitely me[/QUOTE] Lol, I haven't ever spent more than 10 minutes planning out how I'll do something, I usually just do it, doing what I have to to make it work as I go. I just end up getting ideas when I'm playing a game or whatever.
[QUOTE=Jallen;27938990]Lol, I haven't ever spent more than 10 minutes planning out how I'll do something, I usually just do it, doing what I have to to make it work as I go. I just end up getting ideas when I'm playing a game or whatever.[/QUOTE] I used to do it like that, but I just kept coding into corners I couldn't get out of without major rethinking.
[QUOTE=esalaka;27938763]There's even a pseudocode implementation in there [code] Input: n > 3, an odd integer to be tested for primality; Input: k, a parameter that determines the accuracy of the test Output: composite if n is composite, otherwise probably prime write n − 1 as 2s·d with d odd by factoring powers of 2 from n − 1 LOOP: repeat k times: pick a random integer a in the range [2, n − 2] x ← ad mod n if x = 1 or x = n − 1 then do next LOOP for r = 1 .. s − 1 x ← x2 mod n if x = 1 then return composite if x = n − 1 then do next LOOP return composite return probably prime [/code] [editline]8th February 2011[/editline] I mean that's probably the easiest way to explain it[/QUOTE] To me, that's like saying 5^2=25 is explaining squaring. I can understand what's happening in each step but it's like the code is coming from nowhere. I'd like to know why it works and how it works. The thing the wiki page IS explaining but in it's classical wiki-page-about-math kind of way.
I generally come up with a cool idea, then I start to think about problems I might encounter and how to solve them. I get fed up with this and decide to jump in and see what happens. Soon I run into some issues and I go lay on my bed for a couple of hours thinking, before giving up for the day. Repeat this a few times and then I scrap the project completely.
[QUOTE=Jallen;27938511][url]http://stevenbenner.com/2010/07/the-5-types-of-programmers/[/url] Where do you guys fit in? I'm almost definitely the duct tape one :buddy:[/QUOTE] I'm definitely the perfectionist-type, with a small exception that I don't mind others working on my code, though I do review it afterwards =.= For tests and proof-of-concepts I use duct tape-style coding though.
[QUOTE=Jallen;27938511][url]http://stevenbenner.com/2010/07/the-5-types-of-programmers/[/url] Where do you guys fit in? I'm almost definitely the duct tape one :buddy:[/QUOTE] I'm definitely the one who doesn't care what kind of type of programmer other people are, now please stop.
I decided to go with making a really simple physics engine to power my platform game. I've got the force class done, here it is. Force.h [code] #ifndef FORCE_H #define FORCE_H #include <SFML/Graphics.hpp> #include "Constants.h" class Force { public: Force(sf::Sprite& get); ~Force(); void Init(sf::Sprite& get, float str, direction newdir, int lifet, float lifelength); void Apply(); float GetStrength() { return Strength; } void SetStrength(float val) { Strength = val; } direction Getdir() { return dir; } void Setdir(direction val) { dir = val; } float Getlifetime() { return lifetime; } void Setlifetime(float val) { lifetime = val; } bool isAlive() {return alive;}; protected: private: sf::Sprite& spr; float Strength; direction dir; float lifetime; int lifeType; bool alive; sf::Clock time; float curtime; }; #endif // FORCE_H [/code] Force.cpp [code] #include "Force.h" Force::Force(sf::Sprite& get) : spr(get) { //ctor //sf::Sprite newspr; //spr = newspr; } Force::~Force() { //dtor } void Force::Init(sf::Sprite& get, float str, direction newdir, int lifet, float lifelength) { spr = get; Strength = str; dir = newdir; lifeType = lifet; lifetime = lifelength; curtime = 0; if(lifeType == 1) { time.Reset(); } alive = true; } void Force::Apply() { bool go = false; if(!alive) return; if(lifeType == 0) // frames { if(curtime < lifetime) { curtime++; go = true; } else alive = false; } if(lifeType == 1) //seconds { curtime = time.GetElapsedTime(); if(curtime < lifetime) { go = true; } else alive = false; } if(lifeType == -1) //forever { go = true; } if(!go) return; if(dir == DIR_UP) { spr.SetY(spr.GetPosition().y - 1); } if(dir == DIR_DOWN) { spr.SetY(spr.GetPosition().y + 1); } if(dir == DIR_LEFT) { spr.SetX(spr.GetPosition().x - 1); } if(dir == DIR_RIGHT) { spr.SetX(spr.GetPosition().x + 1); } } [/code] Constants.h [code] typedef int direction; const direction DIR_UP = 0; const direction DIR_RIGHT = 1; const direction DIR_DOWN = 2; const direction DIR_LEFT = 4; const bool FORCE_SECONDS = true; const bool FORCE_FRAMES = false; const int LIFE_FRAMES = 0; const int LIFE_SECONDS = 1; const int LIFE_FOREVER = -1; [/code] init a blank sprite and pass it to the ctor, it will be overwritten. Gravity: force.Init(sprite, 1, DIR_DOWN, LIFE_FOREVER, 0); Then to make something go upwards 1 pixel for 20 frames (1 pixel each frame, so 20 pixels up): force.Init(sprite, 2, DIR_UP, LIFE_FRAME, 20); The strength (second argument) needs to be force of gravity + amount of pixels.
Sorry, you need to Log In to post a reply to this thread.