Started messing around with sfml today. This was my goal. Any Criticism is appreciated.
[media]http://www.youtube.com/watch?v=ixbyimLrr3Y[/media]
C++
[code]#include <SFML/Graphics.hpp>
#include <cmath>
float dist(float,float,float,float);
int main()
{
// Create the main window
sf::RenderWindow App(sf::VideoMode(854, 480), "Snake");
float snake[100][2];
float bulge[100][2];
float bulgeDist;
float oldX = 0;
float oldY = 0;
sf::Clock Clock;
// Start the game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
// Escape key : exit
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();
}
// Get the mouse position
float X = App.GetInput().GetMouseX();
float Y = App.GetInput().GetMouseY();
snake[99][0] = X;
snake[99][1] = Y;
bulge[99][0] = Y-snake[98][1];
bulge[99][1] = snake[98][0]-X;
bulgeDist = dist(0,0,bulge[99][0],bulge[99][1]);
bulge[99][0]/=bulgeDist;
bulge[99][1]/=bulgeDist;
bulge[98][0] = Y-snake[97][1];
bulge[98][1] = snake[97][0]-X;
bulgeDist = dist(0,0,bulge[98][0],bulge[98][1]);
bulge[98][0]/=bulgeDist;
bulge[98][1]/=bulgeDist;
App.Clear();
//if(dist(oldX,oldY,X,Y) > 20)
if(Clock.GetElapsedTime() > 0.01)
{
Clock.Reset();
for(int i = 0; i<99; i++)
{
snake[i][0] = snake[i+1][0];
snake[i][1] = snake[i+1][1];
bulge[i][0] = bulge[i+1][0];
bulge[i][1] = bulge[i+1][1];
}
oldX = X;
oldY = Y;
}
for(int i = 0; i < 99; i++)
{
sf::Shape Snake;
Snake.AddPoint(snake[i][0] + bulge[i][0]*i/5, snake[i][1] + bulge[i][1]*i/5, sf::Color(i*2.55,255-i*2.55, 0));
Snake.AddPoint(snake[i][0] - bulge[i][0]*i/5, snake[i][1] - bulge[i][1]*i/5, sf::Color(i*2.55,255-i*2.55, 0));
Snake.AddPoint(snake[i+1][0] - bulge[i+1][0]*i/5, snake[i+1][1] - bulge[i+1][1]*i/5, sf::Color((i+1)*2.55,255-(i+1)*2.55, 0));
Snake.AddPoint(snake[i+1][0] + bulge[i+1][0]*i/5, snake[i+1][1] + bulge[i+1][1]*i/5, sf::Color((i+1)*2.55,255-(i+1)*2.55, 0));
App.Draw(Snake);
}
// Finally, display the rendered frame on screen
App.Display();
}
return EXIT_SUCCESS;
}
float dist(float x1, float y1, float x2, float y2)
{
return pow(pow(x2-x1,2)+pow(y2-y1,2),0.5);
}
[/code]
[QUOTE=MadPro119;37160265]I fell like there should be a thread where people can request art for programs and people can come in an do requests. Nothing extremely extensive but something like that would be pretty cool, would give me something to do and some practice.[/QUOTE]
The question is where would a thread like that go? Programming... probably not...
And I was going to edit but....
[img]http://fi.somethingawful.com/safs/smilies/b/6/yotj.001.gif[/img] 4,001st post [img]http://fi.somethingawful.com/safs/smilies/b/6/yotj.001.gif[/img]
[QUOTE=luck_or_loss;37161201]Started messing around with sfml today. This was my goal. Any Criticism is appreciated.
[media]http://www.youtube.com/watch?v=ixbyimLrr3Y[/media]
C++
[code]snip
[/code][/QUOTE]
Instead of using 2 floats for x and y use a sf::Vector2f, much easier.
[QUOTE=Lord Ned;37158880]You're seriously asking people to pay $1.60 for a game with that art style?[/QUOTE]
People should pay for someone's work. If they don't like graphics, they will not buy it.
BTW game looks like fun. Good work :)
[QUOTE=MadPro119;37161943]The question is where would a thread like that go? Programming... probably not...
And I was going to edit but....
[img]http://fi.somethingawful.com/safs/smilies/b/6/yotj.001.gif[/img] 4,001th post [img]http://fi.somethingawful.com/safs/smilies/b/6/yotj.001.gif[/img][/QUOTE]
The programming forum (or xXxf240xXx as I like to call it) moves slowly enough to accommodate something like that, I think. I mean, what other threads are there, really? WAYWO, WDYNHW, and Electronics; that's about it.
What Are You Not Working On Because You Need Art v1
[QUOTE=Nigey Nige;37163239]The programming forum (or xXxf240xXx as I like to call it) moves slowly enough to accommodate something like that, I think. I mean, what other threads are there, really? WAYWO, WDYNHW, and Electronics; that's about it.
What Are You Not Working On Because You Need Art v1[/QUOTE]
I feel like I should get some kind of go ahead from someone or more people.
[QUOTE=chimitos;37138358]I always just have a dev_mode Boolean.[/QUOTE]
#ifdef _DEBUG?
[QUOTE=SiPlus;37163330]#ifdef _DEBUG?[/QUOTE]
i prefer #ifdef EBUG so I can use -DEBUG on the command line
[QUOTE=swift and shift;37166362]i prefer #ifdef EBUG so I can use -DEBUG on the command line[/QUOTE]
Clever
[editline]10th August 2012[/editline]
Same trick as with libiberty
-snip late as usual-
[QUOTE=esalaka;37166487]Same trick as with libiberty[/QUOTE]
Back in the old Ruby 1.8 days when RubyGems wasn't loaded by default, you could use 'ruby -rubygems your_script.rb' on the command line.
That worked because RubyGems stuck a file called 'ubygems.rb' in your lib/ that went ahead and loaded 'rubygems' properly
I've got my raspberry pi transcribing morse code input from GPIO:
[vid]http://filesmelt.com/dl/IMG_0072.webmvp8_.webm[/vid]
It's adaptive, so based on classifying the last pulse as a dot or dash it will try to predict the length of your next dot/dash, as well as letter and word gaps. It goes through a low-pass filter, so a few erratic pulses won't throw it off but it will keep up with any changes in speed.
The whole thing scales, so hopefully I can hook up some ultra-fast morse recordings and try to transcribe them.
The clump of wires and stuff is just an oscillator, it makes the loudspeaker buzz when you press the key down. I think this is more programming than electronics?
Got height maps working properly:
[img_thumb]http://i47.tinypic.com/35ic6so.jpg[/img_thumb]
Any ideas as to where I go from here? I obviously want to make it look alot better and will start working on multi texturing it. But does anybody have any good pointers as to where I go from here?
Calculate normals in shader.
[img]http://desmond.imageshack.us/Himg502/scaled.php?server=502&filename=capturedh.png&res=landing[/img]
Made a defect sphere in HLSL and started working on my demo framework (most probably another project that will never be completed)
[QUOTE=laylay;37168778]Calculate normals in shader.[/QUOTE]
Lots of people tell me to do this but I dont understand how to, (atleast not with out geometry shader)
Say you use [URL="http://www.opengl.org/wiki/Calculating_a_Surface_Normal"]the basic method[/URL] yoou need to know all 3 verticies of the triangle, where as you usually only know the current position that the shader is working on.
Not to ention if you were trying to do [URL="http://en.wikipedia.org/wiki/Phong_shading"]Phong Interpolation[/URL]
[QUOTE=Richy19;37169259]Lots of people tell me to do this but I dont understand how to, (atleast not with out geometry shader)
Say you use [URL="http://www.opengl.org/wiki/Calculating_a_Surface_Normal"]the basic method[/URL] yoou need to know all 3 verticies of the triangle, where as you usually only know the current position that the shader is working on.
Not to ention if you were trying to do [URL="http://en.wikipedia.org/wiki/Phong_shading"]Phong Interpolation[/URL][/QUOTE]
It can still be calculated because you have the heights of the surrounding vertices. (assuming you have the hightmap as a sampler, you can just sample the surrounding 4 cells)
Here's some old shader code that does the job.
[URL="http://pastie.org/private/w2y2muq1nlfcgoxrkc0fiw"]http://pastie.org/private/w2y2muq1nlfcgoxrkc0fiw
[/URL]
There's a blog post somewhere that explains it much better but I can't find it right now.
[img]https://dl.dropbox.com/u/99765/terrain343.png[/img]
Because the Mari0 fullscreen on the 1680x1050 monitors leaves a black bar at the bottom, I whipped up a display of the stat tracking I added earlier.
The result/effort ratio is really nice so I'm posting it here. Took me less than 10 minutes. Updates live, too.
[img]http://i.imgur.com/YrbXv.gif[/img]
[QUOTE=Maurice;37172385]Because the Mari0 fullscreen on the 1680x1050 monitors leaves a black bar at the bottom, I whipped up a display of the stat tracking I added earlier.
The result/effort ratio is really nice so I'm posting it here. Took me less than 10 minutes. Updates live, too.
[img]http://i.imgur.com/YrbXv.gif[/img][/QUOTE]
That's cool and all, but why not just adjust your code to render to the full screen instead of having black bars at all?
[editline]sorry[/editline]
Sorry for the content less page king, I promise I'll have something to show in the upcoming weeks!
[QUOTE=Matt-;37172444]That's cool and all, but why not just adjust your code to render to the full screen instead of having black bars at all?[/QUOTE]
Because I can't have the game at a scale of 4.15. That'll look shit.
[img]http://i.imgur.com/CWUR9.png[/img]
See all that unwanted single pixel stuff? It makes me wanna PUKE. I wanna go in there and MURDER that brick block's middle line for its crimes against pixel graphics.
[QUOTE=Maurice;37172508]Because I can't have the game at a scale of 4.15. That'll look shit.[/QUOTE]
Don't make assets bigger, just render more of the level/background?
It would work for gamescon but it would put players with higher resolution at an advantage
[QUOTE=Matt-;37172532]Don't make assets bigger, just render more of the level/background?[/QUOTE]
That's a pretty high-effort change you're casually suggesting here.
I thought about that but the maps would look just weird with 4 rows of block at the top/bottom (Since this is only for the portal mappack station).
Also it's nice to have the gamename displayed somewhere. Not Tetris 2 and Not Pacman have the same for the fair, and the multiplayer Mari0 one shows the name in way too big letters when nobody is playing.
[QUOTE=Maurice;37172589]That's a pretty significant change you're casually suggesting here.
I thought about that but the maps would look just weird with 4 rows of block at the top/bottom (Since this is only for the portal mappack station).[/QUOTE]
Ah, my apologies. I didn't even think about the portal map pack, for the plain mario one, you could of just rendered more sky, but yes; it would look a bit shit if it was done on the portal map pack.
[QUOTE=Maurice;37172589]That's a pretty high-effort change you're casually suggesting here.
I thought about that but the maps would look just weird with 4 rows of block at the top/bottom (Since this is only for the portal mappack station).
Also it's nice to have the gamename displayed somewhere. Not Tetris 2 and Not Pacman have the same for the fair.[/QUOTE]
Make assets bigger 4x, then with the left over .15x show extra level.
[QUOTE=ief014;37172643]Make assets bigger 4x, then with the left over .15x show extra level.[/QUOTE]
That's exactly what matt suggested, unless he thought I was currently scaling with a factor of 1.
[QUOTE=Maurice;37172887]That's exactly what matt suggested, unless he thought I was currently scaling with a factor of 1.[/QUOTE]
All I really read was you saying "Scaling at 4.15 looks like ass", so I suggested scaling with whole numbers, then the remainder is ignored and a little more level is shown (Barely enough to be an 'advantage').
[QUOTE=Maurice;37172887]That's exactly what matt suggested, unless he thought I was currently scaling with a factor of 1.[/QUOTE]
That is what I thought. :v:
[QUOTE=Matt-;37172968]That is what I thought. :v:[/QUOTE]
Well that's silly then.
With scale 1 it looks like this.
[img_thumb]http://i.imgur.com/qdSbT.png[/img_thumb]
Sorry, you need to Log In to post a reply to this thread.