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.


Messages - Jarwulf

Pages: [1] 2 3
1
Graphics / Crude Shadow Algorerhythm
« on: April 27, 2010, 03:20:16 am »
blech..


Well I had hoped I could find something directly in C++/OpenGL but I guess that was a pipe dream.

 Even though I was willing to attempt to translate the other solutions I'd have to get knee deep in 3D/OpenGL itself (something I had tried to avoid) and learn not only about shadows but all the API basics and more just to make things look right since there apparently are no suitable traditional 2d solutions to this problem.

Try as I might there are no good resources I could find online or in print to learn modern OpenGL and what was available for older versions was disorganized,inconsistent, and often nonfunctional.

Then of course I found out that my card cannot be updated to OpenGL 3 after a long fruitless search which complicates things considerably.

a failed attempt to use an emulator which apparently only works for cards which which can support 3.0 anyway was the last straw.
 

Since 3d appears to be the only option anyway might as well take a gander at what Ogre can do or maybe the Gamemaker example.

2
Graphics / Crude Shadow Algorerhythm
« on: April 26, 2010, 02:51:08 am »
Quote from: "panithadrum"
I recommend you installing Game Maker and open the source of this engine: http://gmc.yoyogames.com/index.php?showtopic=247336


interesting but it looks like I'd have to buy game maker plus I'm not sure if I can simply take the source and integrate it or if I'd have to turn my entire program into a gamemaker project.

3
Graphics / Crude Shadow Algorerhythm
« on: April 26, 2010, 02:39:27 am »
Quote from: "Ashenwraith"
The code to do top down 2D lighting is all over the internet in all languages for years.

But it only is useful if you are going to make a top-down style game.

Just search gamedev and other sites.



Can you point me to some specific examples? The closest one I can find is OrangeTangy's article.

4
Graphics / Crude Shadow Algorerhythm
« on: April 23, 2010, 06:44:20 am »
Quote from: "Ashenwraith"
The problem with dynamic shadows for a 2D game is that the best 2D graphics often simulate 3D or isometric view.

What the shadows are supposed to be like depends entirely on your game.

For most people copying and transforming a sprite creates a good enough shadow.


There are some amazing dynamic shadows you can find simply by browsing through youtube






They all seem to utilize openGl or Directx though. I would borrow a page out of OrangeTangy's book at Gamedev but his stuff is in java and I'm a little iffy on how to integrate Opengl into my existing code. I haven't been able to find any source in C++.


Still I don't see why a similar result wouldn't be possible without opengl if we had more sophisticated blending and collision functions.

5
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));

6
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?

7
Graphics / dynamic shadows
« on: April 11, 2010, 04:14:16 am »
Quote from: "Spodi"
For 2d lighting, you can just draw a lightmap every frame.

1. Create an image equal to the size of the backbuffer (create only once during initialization)
2. Clear the screen with black
3. Use additive blending to draw on light sprites (stretch to increase size, increase color closer to 255/255/255 to increase intensity)
4. Draw all the lights
5. Copy the backbuffer to your lightmap image
6. Clear the screen, draw as normal
7. After you finish drawing, draw your lightmap on top of the screen using Multiply blending

Very simple but versatile 2d lighting using just SFML. :)



That sounds like it'd be enough for static lighting,but I'm interested in workable dynamic lighting. I know that this sort of thing would have probably been dicey just a short time before but I was hoping somebody had come up with a solution for it.

I have some ideas such as checking each pixel to see whether or not an object intersects the line between it and a light source but I'm not sure if they'll be fast enough to be workable for a game.

8
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?

9
Graphics / Re: window generation between states
« on: April 01, 2010, 03:57:32 am »
Quote from: "Mindiell"
Quote from: "Jarwulf"
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.

How can you say the window is frozen ? Is there anything drawn on the window (old menu, new background, anything else) ? If the program is running, isn't there an infinite loop somewhere ?

Can you show us the code about the menu selection ?




So this is the menu


Code: [Select]

//menustate.cc

void MenuState::OnEvent(MainGame *Game, sf::Event Event)
{
switch(Event.Type)
{
case sf::Event::Closed:
Game->Quit();
break;
case sf::Event::KeyPressed:
switch(Event.Key.Code)
{
case sf::Key::Escape:
// Select Last
mMenu.goLast();
break;
case sf::Key::Up:
mMenu.goUp();
break;
case sf::Key::Down:
mMenu.goDown();
break;
case sf::Key::Return:
switch( mMenu.getSelectedItem() )
{
case 0:
// playState
Game->PushState( PlayState::Instance() );
break;
case 1:
// quit
Game->Quit();
break;
default: break;
}
break;
default: break;
}
break;
default: break;
}
}



case 0 is supposed to lead up to this


Code: [Select]


//playstate.cc


using namespace std;
PlayState PlayState::mPlayState;


void PlayState::OnUpdate(MainGame *Game)
{
//run objects on screen
firsthero.UpdateBoy(Windows.GetInput(), direction, Windows,ObjectArray);
currentui.gameuitrack(firsthero.Mass.GetPosition().x,firsthero.Mass.GetPosition().y);
xydistancefinder(firsthero.Mass.GetPosition().x, View1.GetCenter().x,firsthero.Mass.GetPosition().y, View1.GetCenter().y, distancebetweenxmain, distancebetweenymain,unsignedbx,unsignedby);
 View1.Move( distancebetweenxmain,distancebetweenymain);
Windows.SetView(View1);
}

void PlayState::Draw()
{Windows.Clear();
Windows.Draw(BackgroundSprite);
Windows.Draw(currentui.UInter);
Windows.Display();
Windows.Clear();
}



PlayState *PlayState::Instance()
{
    return &mPlayState;
}



Here is main

Code: [Select]


int main(int argc, char *argv[])
{
 
 MainGame Game("SMEE");

// initialize the engine
if( Game.Init() == false )
{
cout << "[!] Window Created : " << WINWIDTH << "*" << WINHEIGHT << "@" << BPP << " - ERROR" << endl;
return EXIT_FAILURE;
}
cout << "[ ] Window Created : " << WINWIDTH << "*" << WINHEIGHT << "@" << BPP << endl;

// load the intro
Game.ChangeState(MenuState::Instance() );
//Game.ChangeState( CIntroState::Instance() );

// main loop
while(Game.isRunning())
{
Game.OnEvent();

Game.OnUpdate();

Game.OnDraw();
}

// cleanup the engine
Game.Cleanup();
cout << "[ ] Cleanup Success" << endl;

cout << "[ ] Exit Success" << endl;
return EXIT_SUCCESS;
}



when I run debugging I see the program bouncing between playstate::OnUpdate and playstate::Draw so I assume the program must be running but the menu window is still there frozen with playstate selected. I only recently experimented with splitting the program into different states. Before the program was split into different states window generation was handled like this.


Code: [Select]

Int main()
{
sf::RenderWindow Window(sf::VideoMode(800, 600, 32), "WINDOW");


Window.Draw(BackgroundSprite);
}



So I guess in summary I need to know how to get rid of the menu graphics and replace it with the graphics from playstate

10
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.

11
Graphics / App.Draw
« on: January 22, 2010, 01:16:45 am »
nvrmind I think I figured it out

12
Graphics / App.Draw
« on: January 22, 2010, 01:10:43 am »
Quote from: "Laurent"
sf::RenderWindow cannot be copied (for obvious reasons), you must pass it by reference to your function.



Alright, I do that and I transfer responsibility for App.Draw to the objects themselves. so for


class obj
{


objaction(sf::RenderWindow& App)
{

App.Draw(Image);
App.Display

}


};


I get a flashing image. If I include App.Clear it gets even worse.

13
Graphics / App.Draw
« on: January 21, 2010, 03:31:33 am »
Quote from: "panithadrum"
Detail about your errors please.



Something about can't access private member  noncopyable. I guess that means a part of App is private and I can't use the whole thing as an argument so I wonder what part of App I can use. What sort of type is Draw?

14
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?

15
General discussions / debugging
« on: January 05, 2010, 11:48:01 pm »
Anyone have an idea? I can use step over to get further in the code but the debugger keeps exiting without hitting all the breakpoints in main or any in other functions.

The program itself doesn't crash when run normally.

Pages: [1] 2 3