[QUOTE=ButtsexV2;27206188]working on an android app that decides what restaurant you should go to because what you want to eat is the hardest fucking decision you will ever make
well I haven't actually ported it to android yet but I've got it partially running as a web app [url=http://www.buttsexv2.co.cc/rroulette/rest.php]here[/url]
[editline]5th January 2011[/editline]
I've just got to localize it (will be adding a zipcode thing eventually) and write the weighting scripts (I'm setting it up so a business can pay me extra to have their name show up more often)[/QUOTE]
[url]http://www.urbanspoon.com/android[/url] ?
[QUOTE=COBRAa;27190437]You mean you're not using any version control?[/QUOTE]
Nah, I've got a git server running right next to me right now, ye olde Dell Dimension 2400. Running arch linux. without a WM. I also have a minecraft server running on there, and I think I have apache running, but there's no use since my ISP blocks port 80 unless you buy their business package for a shitload of cash.
We just make local changes, push it on the git repo on my server, then the other one pulls from the remote branch. I've got it all set up so any one else on the team can easily hop in if they have Eclipse + Android SDK + ADT plugin + EGit.
[QUOTE=foszor;27206379][url]http://www.urbanspoon.com/android[/url] ?[/QUOTE]
similar, but a bit more specialized. it's really meant for local hole in the wall type restaurants that you would never think to stop at. more for people who want to try new things than people who are indecisive. plus, once completed it's going to have modes that looks for bars, nightclubs, fast food, or sit-down restaurants.
[editline]5th January 2011[/editline]
and I'll put a vegetarian mode just because
[editline]5th January 2011[/editline]
for people like me urbanspoon will send me to places I can't legally go like Keesler AFB, places too far away like Perkinston, MS, or places too shitty or too expensive to bother with
Why I torture my self with C, I don't know.
[code]
case ';': {
schar_t tch;
while((tch = fgetc(tin->input)) != EOF && tch != '\n');
if(tch == EOF)
return TOKENIZER_EOF;
while((tch = fgetc(tin->input)) != EOF && tch == ' ');
return tokenizer_translatesymbol(tin, tch);
} break;
[/code]
[editline]4th January 2011[/editline]
I guess I'm not manly enough to use:
[code]
if ...
else if ...
else if ...
else if ...
else if ...
else if ...
else if ...
else if ...
else if ...
else if ...
else if ...
else ...
[/code]
[QUOTE=Overv;27202189]There will be a separate function to retrieve the error.[/QUOTE]
I hate that more than returning error codes.
[QUOTE=Overv;27202189]There will be a separate function to retrieve the error.[/QUOTE]
Why not return a bool from the compile function?
[QUOTE=Overv;27202189]There will be a separate function to retrieve the error.[/QUOTE]
Why not use exceptions?
I'm freaked out by these birds and fishes dying...
[QUOTE=iRzilla;27208111]Wrong thread?[/QUOTE]
nope, just stupid it looks like.
Here's a basic SFML program (My first SFML program) that I made a week ago. It allows the user to draw out semitransparent randomly-colored rectangles on a screen, and has a custom cursor.
Can I get any feedback on the quality of my code? I'd like to know if/how I can improve my codes neatness, readability, professionalism, etc.
[cpp]/* SFML Rectangle Drawer
* Copyright (c) 2010 Drew Gottlieb
* Use however you want.
*/
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <vector>
#include <iostream>
bool init();
bool initCursor();
void mainLoop();
void render();
void logic();
void processEvent(sf::Event *event);
void startDrag();
void stopDrag();
void cleanup();
sf::Randomizer *random;
sf::RenderWindow *window;
sf::Input *input;
sf::Sprite *cursor;
std::vector<sf::Shape*> *shapes;
bool isDragging = false;
/*
* Main - program entrypoint
*/
int main() {
if (init())
mainLoop();
cleanup();
return EXIT_SUCCESS;
}
/*
* Init - Loads resources and initializes logic
*/
bool init() {
// Init window
#ifdef FULLSCREEN
window = new sf::RenderWindow(sf::VideoMode(1920, 1080, 32), "Draw some rectangles!", sf::Style::Fullscreen);
#else
window = new sf::RenderWindow(sf::VideoMode(800, 600, 32), "Draw some rectangles!");
#endif
window->ShowMouseCursor(false);
// Init all else
input = (sf::Input*)&window->GetInput();
if (!initCursor()) return false;
random = new sf::Randomizer();
random->SetSeed(time(0));
shapes = new std::vector<sf::Shape*>();
}
/*
* Loads the cursor
*/
bool initCursor() {
const char *cursorFile = "cursor.PNG";
sf::Image *cursorImage = new sf::Image();
if (!cursorImage->LoadFromFile(cursorFile)) {
std::cerr << "Error loading image: " << cursorFile << std::endl;
return false;
}
cursorImage->CreateMaskFromColor(sf::Color(255, 0, 255));
cursor = new sf::Sprite();
cursor->SetImage(*cursorImage);
cursor->Scale(0.1f, 0.1f);
return true;
}
/*
* Runs the main program loop
*/
void mainLoop() {
while(window->IsOpened()) {
// Update cursor
cursor->SetPosition(input->GetMouseX(), input->GetMouseY());
// Logic
logic();
// Handle window events and updating
sf::Event event;
while (window->GetEvent(event))
processEvent(&event);
render();
}
}
/*
* Renders the current frame
*/
void render() {
// Clear
window->Clear(sf::Color(100, 149, 237));
// Rectangles
for (int i = 0; i < shapes->size(); i++)
window->Draw(*(shapes->at(i)));
// Cursor
window->Draw(*cursor);
// Display
window->Display();
}
/*
* Main per-loop logic
*/
void logic() {
int xMouse = input->GetMouseX(), yMouse = input->GetMouseY();
// Update rectangle dragging
if (isDragging) {
sf::Vector2f vec;
sf::Shape *rect = shapes->back();
vec = rect->GetPointPosition(1);
rect->SetPointPosition(1, vec.x, yMouse);
rect->SetPointPosition(2, xMouse, yMouse);
vec = rect->GetPointPosition(3);
rect->SetPointPosition(3, xMouse, vec.y);
}
}
/*
* Processes Window events
*/
void processEvent(sf::Event *event) {
switch (event->Type) {
case sf::Event::Closed:
window->Close();
break;
case sf::Event::KeyPressed:
if (event->Key.Code == sf::Key::Escape)
window->Close();
break;
case sf::Event::MouseButtonPressed:
startDrag();
break;
case sf::Event::MouseButtonReleased:
stopDrag();
break;
}
}
/*
* Releases all resources
*/
void cleanup() {
if (input) delete input;
if (window) window->Close();
if (window) delete window;
if (cursor) delete cursor;
if (shapes) delete shapes;
}
/*
* Begins dragging out a new rectangle
*/
void startDrag() {
if (isDragging) stopDrag();
// Rectangle colors
sf::Color outlineColor = sf::Color(0, 0, 0);
sf::Color fillColor = sf::Color(random->Random(0, 255), random->Random(0, 255), random->Random(0, 255), 100);
// Get mouse position
int xMouse = input->GetMouseX(), yMouse = input->GetMouseY();
// Add new rectangle to shapes vector
sf::Shape *rect = new sf::Shape();
rect->AddPoint(xMouse, yMouse, fillColor, outlineColor);
rect->AddPoint(xMouse, yMouse + 1, fillColor, outlineColor);
rect->AddPoint(xMouse + 1, yMouse + 1, fillColor, outlineColor);
rect->AddPoint(xMouse + 1, yMouse, fillColor, outlineColor);
rect->SetOutlineWidth(2);
rect->EnableFill(false);
rect->EnableOutline(true);
shapes->push_back(rect);
isDragging = true;
}
/*
* Stops dragging a rectangle
*/
void stopDrag() {
// Enable fill color
sf::Shape *rect = shapes->back();
rect->EnableFill(true);
isDragging = false;
}[/cpp]
well you can start by not having everything in one file.
[QUOTE=haushippo;27208167]nope, just stupid it looks like.[/QUOTE]
Nope. Just all that good fish going to waste...
[QUOTE=efeX;27209369]well you can start by not having everything in one file.[/QUOTE]
It's the smallest of programs. In my opinion it would be silly to split this into multiple files since the program is 100% complete. It's small and simple.
My opinion can change however if you explain why it would be better to split it up into multiple files/classes.
what if someone wanted to put that in their project? they would have to go through and manually put those functions in their code as well as the members.
if you had the core code in a class people could just add the class to their project.
[QUOTE=dag10;27209478]It's the smallest of programs. In my opinion it would be silly to split this into multiple files since the program is 100% complete. It's small and simple.
My opinion can change however if you explain why it would be better to split it up into multiple files/classes.[/QUOTE]
For how simple your program is you don't seem to need masses of classes and files, but when you start working on stuff like games and just all around bigger programs that require more diversity, having everything in one file can make things hard to read.
[QUOTE=Kopimi;27209879]For how simple your program is you don't seem to need masses of classes and files, but when you start working on stuff like games and just all around bigger programs that require more diversity, having everything in one file can make things hard to read.[/QUOTE]
I always split things into multiple files and classes with [i]anything[/i] larger than this program. This program I knew what I was making going into it, and I knew how short it'd be.
For example, I'm currently making a platformer with SFML (for fun!), and I'm having these classes: Game, Level, Platform, Player, Entity. The Game class will also create the RenderWindow, and handle Window messages and Input. Game also has a public method Render(sf::RenderTarget *target) which it will use when rendering to its RenderWindow. This would allow someone (or me) to easily be able to use the game as normal, but have complete control of each rendered frame outside of the Game class. As in, for example, I could have split-screen, or save screenshots.
But aside from the fact that my code above is a single file, are there any other thoughts or suggestions for me to make my code more readable/professional?
I'm making a quick shakespearean insult generator, probably tomorrow I'll post some.
I think I'll add a way to grade insults on quality to influence the probability of any one word being picked.
Here is what my assembler reads (:barf: if you wish):
[code]
; Test.asm
.TEXT
START:
MOV $255, %AA
MOV $0Fh, %AB
SUB %AB, %AA
.BSS
.DATA
text: "Hello World"
len: =text
[/code]
[QUOTE=DevBug;27210289]Here is what my assembler reads (:barf: if you wish):
[code]
; Test.asm
.TEXT
START:
MOV $255, %AA
MOV $0Fh, %AB
SUB %AB, %AA
.BSS
.DATA
text: "Hello World"
len: =text
[/code][/QUOTE]
I should stop being lazy and continue making mine. I've got a book that explains the API, so I have no reason to put it off.
[QUOTE=Overv;27202189]There will be a separate function to retrieve the error.[/QUOTE]
I thought you were making an object oriented C++ library
[QUOTE=ZenX2;27210569][code]...[/code]
How are those?[/QUOTE]
Thou Irish!
Nuff' said.
Why do have to speak the truth :saddowns:
[editline]4th January 2011[/editline]
Thou whoreson rump-fed nut-hook...
I think Combino is stalking my posts.
[editline]5th January 2011[/editline]
[img]http://localhostr.com/file/y3NTjpF/Capture2.PNG[/img]
Combino, have you looked into the blocking of anyhub on various dns services yet?
[img]http://dl.dropbox.com/u/3605545/anyhubblock.png[/img]
[img]http://dl.dropbox.com/u/3605545/anyhubblock2.png[/img]
[QUOTE=sLysdal;27211308][img_thumb]http://dl.dropbox.com/u/3605545/anyhubblock2.png[/img_thumb][/QUOTE]
It's been removed from the OpenDNS blacklist, although I haven't heard back from CSIS. I might try contacting them again
Okay, its getting really annoying since lots of pictures in the WAYWO and on fp in general are hosted on anyhub :/
[editline]5th January 2011[/editline]
[img]http://dl.dropbox.com/u/3605545/anyhubblock3.png[/img]
I did my part :/
[QUOTE=sLysdal;27211721]Okay, its getting really annoying since lots of pictures in the WAYWO and on fp in general are hosted on anyhub :/
[editline]5th January 2011[/editline]
[img_thumb]http://dl.dropbox.com/u/3605545/anyhubblock3.png[/img_thumb]
I did my part :/[/QUOTE]
Are you able to change your DNS settings?
[QUOTE=Combino;27211958]Are you able to change your DNS settings?[/QUOTE]
No, you cant, its forced, if you change DNS you get booted off the internet instantly, ive tried
[QUOTE=DevBug;27203126]Yes that's right, I would get a compiler error from a linker...[/QUOTE]
No, god, fuck, agh.
You won't get the linker error if you compile with that. Without that the headers disable POSIX functions.
I don't care if this has been said earlier I just wanted to note you could've just tried it first.
Sorry, you need to Log In to post a reply to this thread.