Lethn (OP)
Legendary
Offline
Activity: 1540
Merit: 1000
|
|
May 17, 2013, 10:33:03 PM |
|
LOL After all that raging I found that the problem was that I had downloaded 64 bit GLFW binaries instead of 32 bit, I feel like a noob even after all that coding Now I can begin work on my keyboard and mouse interaction
|
|
|
|
Lethn (OP)
Legendary
Offline
Activity: 1540
Merit: 1000
|
|
May 18, 2013, 10:28:41 AM |
|
I found a very nice tutorial on naming objects in OpenGL so you can start interacting with the OpenGL graphics you make, wish all tutorials were as detailed as this. http://www.lighthouse3d.com/opengl/picking/
|
|
|
|
Lethn (OP)
Legendary
Offline
Activity: 1540
Merit: 1000
|
|
May 18, 2013, 07:19:58 PM Last edit: May 18, 2013, 07:37:15 PM by Lethn |
|
#ifdef __cplusplus #include <cstdlib> #else #include <stdlib.h> #endif
#include <SDL/SDL.h>
int main ( int argc, char*, args[] ) {
SDL_Surface* test = NULL; SDL Init ( SDL_INIT_EVERYTHING ); screen = SDL_SetVideoMode ( 640, 480, 32, SDL_SWSURFACE ); test = SDL_LoadBMP ("Test.bmp"); SDL_BlitSurface (test, NULL, screen, NULL) SDL_Flip ( screen ); SDL_Delay ( 2000 ); SDL_FreeSurface( test ); SDL_Quit();
return 0;
}
From various posts and word on the internet I've found that SDL is apparently the library to use, I can see it combines it's code really well and you don't have to worry about downloading extensions for keyboard input like with GLFW so that's already a plus but, I've come across a problem. I'm following the tutorials here: http://lazyfoo.net/SDL_tutorials/lesson01/windows/codeblocks/index.php but the code won't compile! It's strange because the commands were registered by Codeblocks ( IDE I'm using ) and when I started up the SDL sample the code works absolutely fine. Anyone got any advice? I'm going to get on this properly because I think SDL is a pretty nice library but I suspect I'll have to do some digging around like when I was just compiling basic OpenGL, I'm wondering if the code for this tutorial is out of date because the version of the library it said to download was much earlier, it's happened before with previous coding. error: 'args' has not been declared In function 'int SDL_main(int, char*, int*)' error: 'SDL' was not declared in this scope error: expected ';' before 'Init' error: 'screen' was not declared in this scope
||=== Build finished: 4 errors, 0 warnings (0 minutes, 0 seconds) ===|
I think I'm just going to have to do what I did before and work with the sample and learn the code that way so Codeblocks doesn't break.
|
|
|
|
Foxpup
Legendary
Offline
Activity: 4494
Merit: 3180
Vile Vixen and Miss Bitcointalk 2021-2023
|
|
May 19, 2013, 05:24:12 AM |
|
error: 'args' has not been declared
There must be no comma between char* and args[], as they're part of the same declaration (that you have a array of pointers called "args" of type "char"). With the comma, it thinks you have an anonymous pointer of type "char", and something completely separate called "args", though it doesn't know what this thing called "args" is supposed to be, hence the error. error: 'SDL' was not declared in this scope error: expected ';' before 'Init'
You need an underscore between SDL and Init, with no spaces. "SDL_Init" is one function. With a space, it thinks they are two separate functions called "SDL" and "Init" (which don't even exist, causing the first error), and expects a semicolon between them (you always need a semicolon between statements), which is the second error. error: 'screen' was not declared in this scope
You forgot to declare it (or you declared it in the wrong place). You should have "SDL_Surface* screen = NULL;" immediately after (or immediately before) "SDL_Surface* test = NULL;".
|
Will pretend to do unspeakable things (while actually eating a taco) for bitcoins: 1K6d1EviQKX3SVKjPYmJGyWBb1avbmCFM4I am not on the scammers' paradise known as Telegram! Do not believe anyone claiming to be me off-forum without a signed message from the above address! Accept no excuses and make no exceptions!
|
|
|
Lethn (OP)
Legendary
Offline
Activity: 1540
Merit: 1000
|
|
May 19, 2013, 08:49:22 AM Last edit: May 19, 2013, 09:31:55 AM by Lethn |
|
wow thanks a lot Foxpup, that's really interesting, he didn't seem to mention any of this in the troubleshooting for it and so on >_< and this is supposed to be a beginners tutorial lol! I copied it exactly just to see whether I was forgetting or something, but it looks like there are bits wrong with his code, I'll double check again and it looks like there are. Do you know of any up to date tutorials that won't bugger up on the latest version of SDL? I particularly like this library because it means I have to go and make some art assets right away which is nice, anime characters time woot!
|
|
|
|
Foxpup
Legendary
Offline
Activity: 4494
Merit: 3180
Vile Vixen and Miss Bitcointalk 2021-2023
|
|
May 19, 2013, 09:39:47 AM |
|
wow thanks a lot Foxpup, that's really interesting, he didn't seem to mention any of this in the troubleshooting for it and so on >_< and this is supposed to be a beginners tutorial lol! I copied it exactly just to see whether I was forgetting or something, looks like there are bits wrong with his code but I'll double check again and it looks like there are. It's for beginning game programmers, ie, programmers who are experienced at writing other applications and wish to move on to the more specialised field of game programming. This tutorial assumes basic knowledge of C++. If you have never done much programming in C++ before, you should probably start with the basics before continuing. Q: How much C++ do I have know to start game programming? A: For my SDL tutorials, you must have a decent handle on the following concepts: Operators (+, -, *, /, ++, --, +=, -=, etc) Controls (if, else, switch) Loops (while, for) Functions Structs Arrays References Pointers Classes and Objects How to use a template. Bitwise and/or.
The articles might require you to know more, but they'll mention it beforehand. Of course the more C++ you know, the better. To make anything complex you'll need to know inheritance, polymorphism, templates, and STL. Eventually you'll need to know exceptions, operator overloading and the whole language.
Make sure you know these concepts well. Don't just skim over them in a C++ reference book. It doesn't matter how much Java/Python/C#/Visual Basic/ASM/HTML/whatever you know. You have to know C++ to be able to learn from the tutorials/articles.
Do you know of any up to date tutorials that won't bugger up on the latest version of SDL? I particularly like this library because it means I have to go and make some art assets right away which is nice, anime characters time woot! I'm pretty sure this tutorial is up to date with SDL 1.2 (the latest stable version). SDL 2 has a lot of changes, but I think it's mostly the addition of OpenGL and haptic support, I'm not sure how much (if any) of the 2D graphics stuff is being changed. Anyway, SDL 2 hasn't been officially released yet, so it's a moot point.
|
Will pretend to do unspeakable things (while actually eating a taco) for bitcoins: 1K6d1EviQKX3SVKjPYmJGyWBb1avbmCFM4I am not on the scammers' paradise known as Telegram! Do not believe anyone claiming to be me off-forum without a signed message from the above address! Accept no excuses and make no exceptions!
|
|
|
Lethn (OP)
Legendary
Offline
Activity: 1540
Merit: 1000
|
|
May 19, 2013, 09:41:53 AM |
|
Alright, thanks for the help, I'll steamroll through this like I've been doing with OpenGL just need to put the time in.
|
|
|
|
Lethn (OP)
Legendary
Offline
Activity: 1540
Merit: 1000
|
|
May 19, 2013, 09:53:37 AM Last edit: May 19, 2013, 10:28:17 AM by Lethn |
|
Finally! Got it sorted! Image came out a bit weird but I think that's more to do with the resolution I used, thanks for the help again, here's the now updated and working code. #ifdef __cplusplus #include <cstdlib> #else #include <stdlib.h> #endif
#include <SDL/SDL.h>
int main( int argc, char* args[] )
{
SDL_Init; ( SDL_INIT_EVERYTHING ); SDL_Surface* screen = NULL; SDL_Surface* test = NULL;
screen = SDL_SetVideoMode( 500, 500, 32, SDL_SWSURFACE );
test = SDL_LoadBMP( "test.bmp" );
SDL_BlitSurface( test, NULL, screen, NULL );
SDL_Flip( screen ); SDL_Delay( 2000 );
SDL_FreeSurface( test );
SDL_Quit();
return 0; }
For future reference I think the biggest problem was SDL_Init( SDL_INIT_EVERYTHING ); because on the tutorial he put that after the SDL_surface commands rather than before.
|
|
|
|
Lethn (OP)
Legendary
Offline
Activity: 1540
Merit: 1000
|
|
May 27, 2013, 09:20:35 AM Last edit: May 27, 2013, 10:48:28 AM by Lethn |
|
I've been through some changes, because SDL just seems to be filled with outdated tutorials and such, I really can't be bothered combing through the code and fixing problem after problem that's completely unncessary. So I went and looked at SFML which seems to be much better supported and low and behold the commands provided in most tutorials work properly, I've been able to even get some basic interaction going with it. I'll have to have a think now on what I'm going to make and I have a basic platformer in mind, next up to learn will be sprites and collision I guess.
#include <SFML/Graphics.hpp>
int main() { sf::RenderWindow window(sf::VideoMode(800, 600), "Lethn 2D Engine"); sf::CircleShape circle1 ( 20 ); circle1.setPosition( 30, 30 ); sf::CircleShape circle2 ( 20); circle1.setPosition( 200, 260 ); circle2.setPosition( 600, 260 ); circle1.setFillColor( sf::Color::Red ); circle1.setOutlineColor( sf::Color::Magenta ); circle1.setOutlineThickness( 3 ); circle2.setFillColor( sf::Color::Blue ); circle2.setOutlineColor( sf::Color::Cyan ); circle2.setOutlineThickness( 3 );
while (window.isOpen()) { sf::Event event; while (window.pollEvent(event))
if ( sf::Keyboard::isKeyPressed( sf::Keyboard:: W ) )
{ circle1.move ( 0, -5 ); }
else if ( sf::Keyboard::isKeyPressed( sf::Keyboard:: A ) )
{ circle1.move ( -5, 0 ); }
else if ( sf::Keyboard::isKeyPressed( sf::Keyboard:: D ) )
{ circle1.move ( 5, 0 ); }
else if ( sf::Keyboard::isKeyPressed( sf::Keyboard:: S ) )
{ circle1.move ( 0, 5 ); } { if (event.type == sf::Event::Closed) window.close(); }
window.clear(); window.draw(circle1); window.draw(circle2); window.display(); }
return 0; }
|
|
|
|
jackjack
Legendary
Offline
Activity: 1176
Merit: 1260
May Bitcoin be touched by his Noodly Appendage
|
|
May 27, 2013, 11:54:34 AM |
|
Same happened for me I never managed to get SDL working even for small tasks whereas SFML is a pleasure to use
|
Own address: 19QkqAza7BHFTuoz9N8UQkryP4E9jHo4N3 - Pywallet support: 1AQDfx22pKGgXnUZFL1e4UKos3QqvRzNh5 - Bitcointalk++ script support: 1Pxeccscj1ygseTdSV1qUqQCanp2B2NMM2 Pywallet: instructions. Encrypted wallet support, export/import keys/addresses, backup wallets, export/import CSV data from/into wallet, merge wallets, delete/import addresses and transactions, recover altcoins sent to bitcoin addresses, sign/verify messages and files with Bitcoin addresses, recover deleted wallets, etc.
|
|
|
Lethn (OP)
Legendary
Offline
Activity: 1540
Merit: 1000
|
|
June 01, 2013, 12:03:00 PM |
|
I'm working through some simple point and click mouse events and stuff but does anyone have any tips for how I could get the move command to work or if that's what is necessary at all? What I'm trying to do is to get my sprite to move to the position of where I left click like an RTS or point and click RPG, I haven't had problems with keyboard commands so far but this is causing problems for me.
while (window.isOpen()) {
sf::Event event; while (window.pollEvent(event))
if ( event.type == sf::Event::MouseButtonPressed )
{
if ( event.mouseButton.button == sf::Mouse::Left )
{
sf::Event.mouseButton.x << std::end1; sf::Event.mouseButton.y << std::end1; spriteplayerstanding1.move ( MouseButtonPressed ); }
{ if (event.type == sf::Event::Closed) window.close(); }
|
|
|
|
Lethn (OP)
Legendary
Offline
Activity: 1540
Merit: 1000
|
|
June 02, 2013, 04:31:50 PM Last edit: June 03, 2013, 08:04:52 AM by Lethn |
|
I found out in an old post finally how to do it Correct snytax is: sf::Event event; while (window.pollEvent(event))
if (sf::Mouse::isButtonPressed ( sf::Mouse::Left ) )
{ spritename1.move ( sf::Mouse::getPosition( window ).x, sf::Mouse::getPosition( window ).y ); }
{ if (event.type == sf::Event::Closed) window.close(); }
I was using the command separately and not in the right order, my only problem now is the warping.
|
|
|
|
Lethn (OP)
Legendary
Offline
Activity: 1540
Merit: 1000
|
|
June 03, 2013, 08:06:09 AM |
|
Okay I have partially got things working, my only problem now is that I'm only able to specifically drag my sprite to the x and y coordinates of the cursor rather than all around. while (window.isOpen()) {
sf::Event event; while (window.pollEvent(event))
if (sf::Mouse::isButtonPressed ( sf::Mouse::Left ) )
{ spritename1.move ( sf::Mouse::getPosition( window ).x >50, sf::Mouse::getPosition( window ).y >50 ); }
|
|
|
|
r3wt
|
|
June 03, 2013, 08:16:42 AM |
|
any php'ers in the house? i'm making a mess of this form this form does everything i basically need it to do, but i'm having problems adding anymore logic to it. i need for it to check the and for common elements of emails and urls for example "@" and "http://" .also wierdly it displays the div when i load the page, when it should display either the or nothing. i wrote this tonight but i've been having the rewrititis for the last couple of hours. decided it might be wise for me to ask an experience php programmer(s) for advice. session_start();
$name = $_POST['name']; $email = $_POST['email']; $url = $_POST['url']; $title = $_POST['title']; $message = $_POST['message']; $code- $_POST['code'];
$data = "$name | $email $url | $title - $message "; if(strtolower($_POST['code']) == $_SESSION['rand_code']) { $accept = "Your Entry is being processed"; $fh = fopen("redacted.txt", "a"); //write and close fwrite($fh, $data); } else { $error = "All Fields Are Required."; } The original version was more complex with multiple error messages. the one shown and one for the captcha. couldn't get it to work though.
|
My negative trust rating is reflective of a personal vendetta by someone on default trust.
|
|
|
jackjack
Legendary
Offline
Activity: 1176
Merit: 1260
May Bitcoin be touched by his Noodly Appendage
|
|
June 03, 2013, 08:22:36 AM |
|
- email+url: look at regex
- you don't fclose
- I don't see any echo so how can you display error or accept?
|
Own address: 19QkqAza7BHFTuoz9N8UQkryP4E9jHo4N3 - Pywallet support: 1AQDfx22pKGgXnUZFL1e4UKos3QqvRzNh5 - Bitcointalk++ script support: 1Pxeccscj1ygseTdSV1qUqQCanp2B2NMM2 Pywallet: instructions. Encrypted wallet support, export/import keys/addresses, backup wallets, export/import CSV data from/into wallet, merge wallets, delete/import addresses and transactions, recover altcoins sent to bitcoin addresses, sign/verify messages and files with Bitcoin addresses, recover deleted wallets, etc.
|
|
|
Lethn (OP)
Legendary
Offline
Activity: 1540
Merit: 1000
|
|
June 03, 2013, 08:27:04 AM |
|
yey! more people posting their code other than me!
|
|
|
|
Mike Christ
aka snapsunny
Legendary
Offline
Activity: 1078
Merit: 1003
|
|
June 03, 2013, 08:29:50 AM |
|
Phew, I need to take a break.
|
|
|
|
r3wt
|
|
June 03, 2013, 08:30:23 AM |
|
regex? what is that exactly? i'm afraid i don't know much about it. i'm self taught so my knowledge is *extremely limited* the script works fine without it.. is it really necessary? - I don't see any echo so how can you display error or accept?
i call the echo down below in the form: <div id="result"> <? if(!empty($error)) echo '<div class="error"><img src="fail.png" /> '.$error.'</div>'; ?> <? if(!empty($accept)) echo '<div class="accept"> <img src="ok.png" />'.$accept.'</div>'; ?> </div>
|
My negative trust rating is reflective of a personal vendetta by someone on default trust.
|
|
|
jackjack
Legendary
Offline
Activity: 1176
Merit: 1260
May Bitcoin be touched by his Noodly Appendage
|
|
June 03, 2013, 08:39:56 AM |
|
regex? what is that exactly? i'm afraid i don't know much about it. i'm self taught so my knowledge is *extremely limited* the script works fine without it.. is it really necessary? - I don't see any echo so how can you display error or accept?
i call the echo down below in the form: <div id="result"> <? if(!empty($error)) echo '<div class="error"><img src="fail.png" /> '.$error.'</div>'; ?> <? if(!empty($accept)) echo '<div class="accept"> <img src="ok.png" />'.$accept.'</div>'; ?> </div>
Regex are something specifically designed to validate patterns. Warning: that's pretty annoying. Sure it works without fclose but you're using RAM for nothing and you're locking the file for every other process until the PHP script ends. Oh, and PHP gurus will kill you. Looks ok, so I'd put many echo's in your big 'if' to see what happens: check all your variables at many times.
|
Own address: 19QkqAza7BHFTuoz9N8UQkryP4E9jHo4N3 - Pywallet support: 1AQDfx22pKGgXnUZFL1e4UKos3QqvRzNh5 - Bitcointalk++ script support: 1Pxeccscj1ygseTdSV1qUqQCanp2B2NMM2 Pywallet: instructions. Encrypted wallet support, export/import keys/addresses, backup wallets, export/import CSV data from/into wallet, merge wallets, delete/import addresses and transactions, recover altcoins sent to bitcoin addresses, sign/verify messages and files with Bitcoin addresses, recover deleted wallets, etc.
|
|
|
r3wt
|
|
June 03, 2013, 08:55:47 AM |
|
regex? what is that exactly? i'm afraid i don't know much about it. i'm self taught so my knowledge is *extremely limited* the script works fine without it.. is it really necessary? - I don't see any echo so how can you display error or accept?
i call the echo down below in the form: <div id="result"> <? if(!empty($error)) echo '<div class="error"><img src="fail.png" /> '.$error.'</div>'; ?> <? if(!empty($accept)) echo '<div class="accept"> <img src="ok.png" />'.$accept.'</div>'; ?> </div>
Regex are something specifically designed to validate patterns. Warning: that's pretty annoying. Sure it works without fclose but you're using RAM for nothing and you're locking the file for every other process until the PHP script ends. Oh, and PHP gurus will kill you. Looks ok, so I'd put many echo's in your big 'if' to see what happens: check all your variables at many times. ahh, so thats why i couldn't get the form to save when i was accessing the file from the "admin console i built" to edit/read it. i know that flat databases are out of style but i find it useful for my manual review process. i don't wanna give people access to the database directly. trying to prevent spam sites and links. so what would the fclose command be for this particular setup? i tried it several diffent was and keep getting the error message: php expects parameter 1 to be resource, boolean given in "...../submit.php" on line ...
|
My negative trust rating is reflective of a personal vendetta by someone on default trust.
|
|
|
|