Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Jarwulf

Pages: [1]
1
Graphics / Crude Shadow Algorerhythm
« on: April 23, 2010, 01:17:04 am »
Alright after a bit of thinking about how I could create dynamic shadows I wrote a crude algorerhythm that sort of approaches the problem using SFML. The general idea is that the light source casts out rays and the collision locations of these rays help shape the general outline of the light

Its very simplistic and has quite a few problems that probably will prevent it from working properly let alone being suitable for real time shadows but its simply a jumping board.

What are some suggestions,improvement, or outright replacements you can come up with?  And if there are any outright mistakes feel free to point that out as well I didn't check this in the compiler.

Some Current Problems
1. For and while loops: can eliminate them but replacing them with if statements can cause problems with the light not being generated properly.
2. The light ray movement hinders the ability of the light to change quickly
3. Low resolution: Can be solved by increasing amount of rays cast but this may slow things down.
4. Testing rays for collisions against all objects: Slow but I'm not sure what other options there may be.
5. Light Polygon might not form properly if concave.

Code: [Select]
//Point light:

//place pixel light
light.SetPosition(200,200);

//place light circle
lightcircle.SetPosition(200,200)

//Optional Step: Check for collision of light circle can be substituted with continuous scanning

for(itcirchk=0;itcirchk<=objectlist.size();itcirchk++)
{
  if (CircleTestCollision(lightcircle,object[itcirchk].Mass)==1)
  {//If collision, start raycasting every x degrees to form shape of light polygon
  xlightray=.1;
  ylightray=-.9;

    do
    {

      while(distancebetweenobjects(light.Mass,bullet)<=100)//while the ray is in the light's range
      {
 lightray.move(xlightray,ylightray);

       for (itraycolchk=0;itraycolchk<=objectlist.size();itraycolchk++)
   {//every step check ray for collision against all objects
     if (PixelPerfectCollisionCheck(lightray,objectlist[itraycolchk])==1);
     { //If collision record ray location and add to polygon generation vector.
          recordpoint.x=lightray.GetPosition().x;
          recordpoint.y=lightray.GetPosition().y;
          pointvector.pushback(recordpoint);
          pointreached=1;
     break;//move on to next ray
     }
        }

 if pointreached==1;
 break;//break out of loop to cast next ray
     
   else if (distancebetweenobjects(light.Mass,lightray)>=100)
   {//if ray has traveled light's range without collision add another point to polygen vector
   recordpoint.x=lightray.GetPosition().x;
        recordpoint.y=lightray.GetPosition().y;
        pointvector.pushback(recordpoint);
   }

 }

//change direction ray will travel in clockwise fashion

 if ( xlightray>=0 && xlightray<=1 && ylightray>=-1 && ylightray <=0)
 {//first quadrant
 xlightray=xlightray+.1;
 ylightray=ylightray+.1;
 }

 else if (xlightray >=0 xlightray<=1 && ylightray>=0 && ylightray>=1 )
 {//second quad
 xlightray=xlightray-.1;
 ylightray=ylightray+.1;
 }

 else if (xlightray>=-1 && xlightray<=0  && ylightray<=1 && ylightray>=0)
 {//third quad
      xlightray=xlightray-.1;
 ylightray=ylightray-.1;
 }

 else (xlightray>=-1 && xlightray<=0 && ylightray<=0 && ylightray>=-1)
 {//fourth quad
 xlightray=xlightray+.1;
 ylightray=ylightray-.1;
 }

}while (xlightray!=0 && ylightray!=-1)//run loop till rays have been cast in full circle


  }

}

//Draw light polygon based on points in vector
for (itpolydrw=0;itpolydrw<=pointvector.size();itpolydrw++)
LightPolygon.AddPoint(pointvector[itpolydrw].x,pointvector[itpolydrw].y)

//Color polygon
LightPolygon.SetColor(sf::Color(255, 255, 255, 200));

2
General discussions / opengl tutorial
« on: April 19, 2010, 07:55:10 am »
I think this is a hardware problem but when I did the opengl tutorial instead of getting just a rotating cube I get a two cubes. One normal one and a flashing one on top of it. Anyone know what's wrong?

3
Graphics / dynamic shadows
« on: April 09, 2010, 08:50:32 pm »
does SFML have any built in resources to ease dynamic shadow and light generation or do I have to jump directly into OpenGL?

4
Graphics / window generation between states
« on: March 31, 2010, 01:50:36 am »
I'm having problems with generating a window for my gameplay state using C++ and SFML. I'm at a menu screen I select an option and then the window is just frozen. I think somethings wrong with how I'm trying to draw the window since debugging shows that the program is running. Are there any mistakes that you can see?  


This is a skeleton of how the drawing is set up.

Code: [Select]

//playstate.h
sf::RenderWindow Window;

void Draw();

//playstate.cc

void MenuState::Draw()
{
Window.Clear(sf::Color(50, 50, 150));
Window.Draw(BackgroundSprite);
Window.Draw(currentui.UInter);

// Display window contents on screen
Window.Display();
Window.Clear();
}



The menu which precedes the playstate is set up like this

Code: [Select]

//menustate.h


void Draw(sf::RenderWindow &Window);

//menustate.cc

void MenuState::Draw(sf::RenderWindow &Window)
{
Window.Clear(sf::Color(50, 50, 150));
Window.Draw(MenuSprite);
Window.Display();
}




The menu appears to work until I select the play option. I can't set up sf::RenderWindow Window in the playstate like it is in the menu because other functions besides Draw need access to it.

5
Graphics / App.Draw
« on: January 21, 2010, 01:20:28 am »
Hi I have

sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");



I have several objects on screen. I currently have all the objects displayed by
using App.Draw from main().


I want to make it so that the objects display under certain circumstances ie a collision between two causes them to disappear. So I figure I should transfer whether an object uses App.Draw from main to the object itself,controlled by an (if) statement. When I try to do something like

Object.objectwork(App);

I get errors. How would I accomplish what I want?

6
General discussions / debugging
« on: January 03, 2010, 11:37:38 pm »
When I try to start debugging a SFML project it simply exits out without hitting the breakpoints whereas things work fine with a simple console project. Do you have to use the debugging dlls to debug or is there something else wrong? Can I just replace the release dlls or is there some other settings I have to change?

7
General discussions / Shape Collision
« on: November 26, 2009, 07:42:23 am »
Hi, the wiki lists sprite collision detection here

http://www.sfml-dev.org/wiki/en/sources/simple_collision_detection

but I'm also interested in collisions between Shapes and Strings as well as collisions between different catagories of objects. How could it be modified to make this possible?

Thanks

8
Graphics / Animated Wackiness
« on: September 30, 2009, 01:30:06 am »
I used Hiura's Animated Class with good results. But there is a hiccup when I try to place it into one of my classes. I have a class called wanderbot which has Animated BotImage as a member.

BotImage works fine when it is declared in main() but if I put it in wanderbot and put  

Code: [Select]
Basicbot.BotImage(botgo[UP],0.1f);

to start the animation in main it says.

Code: [Select]
term does not evaluate to a function taking two arguments.


I can take out the code and it compiles fine but the bot animation is jiggling and blurry.

9
General discussions / strings or projectiles?
« on: September 23, 2009, 09:00:57 pm »
I currently have a bot that wanders around until the player gets close enough then it moves toward the player. This is problematic in an area full of obstacles so I've come up with two main options.

I can draw a string to connect both objects that prevents the bot from 'seeing' the player if it intersects with the maze.

I can shoot out an invisible projectile sprite from the bot every game loop which prevents the bot from 'seeing' the player if it intersects with the maze.

If I do the first I'll have to figure out how to adapt the wiki's collision detection to Shapes but the second might be increased overhead. I want to eventually adapt whatever method I use for bots that 'see' the normal way instead of through simple proximity

Which one is the best use of resources? Or is there a better way?

10
General discussions / per pixel collision detection
« on: September 21, 2009, 08:41:06 am »
It's simple enough drawing one bounding rectangle but I figure it'll take ages to apply this to an entire maze.

I need someway to relatively quickly and painlessly make a maze sprite out of photoshop solid. I heard blitting/per pixel collision detection might work. Does anybody have any sample code for a simple algorithm?

Thanks...

11
System / Passing variables to threads
« on: September 16, 2009, 02:04:10 am »
I have a while loop which handles a fired bullet. The bullet goes to x distance than disappears. While the bullet is traveling the character cannot move.

To solve this I tried to create a class to start a new thread. In order for it to function I need to pass the bullet sprite and the timer used to measure the bullet distance to the thread/class instance but I don't know a solution besides making them both external. Can anybody show me how to pass this information instead?


(I also have 'App' update the scenery inside the loop while the bullet moves but I figure I can get rid of it once I have a separate working thread)

12
Graphics / Animating Sprites
« on: September 12, 2009, 02:06:00 am »
How would you go about using several images to animate a moving sprite? Sprite.move seems to be geared just to one static image.

13
General discussions / Tutorial request
« on: August 30, 2009, 08:52:27 am »
Can you include in your tutorials the necessary library files? Not knowing what to link to makes it harder for some beginners.  :D

Pages: [1]
anything