Author

Topic: The Coding Thread (Read 2753 times)

hero member
Activity: 686
Merit: 504
always the student, never the master.
December 08, 2013, 04:58:10 AM
#53
Fuck no lol Cheesy but if we keep bumping this thread maybe someone else will take a look, I'm learning C++ and SFML currently.

SFML? SAD FUCK MY LIFE LANGUAGE ? lol
legendary
Activity: 1540
Merit: 1000
November 27, 2013, 05:37:58 AM
#52
Fuck no lol Cheesy but if we keep bumping this thread maybe someone else will take a look, I'm learning C++ and SFML currently.
hero member
Activity: 686
Merit: 504
always the student, never the master.
November 27, 2013, 05:31:35 AM
#51
I'm bumping the coding thread Tongue I want to post up some more code here soon Cheesy

can you debug an sql query? i can't get my form to work for some odd strange reason.

Code:
Ban A user

echo $account?>" />




if (isset($_POST["to_ban"]))
{
$banby mysql_real_escape_string(strip_tags($_POST["banby"]));
$to_ban mysql_real_escape_string(strip_tags($_POST["to_ban"]));
$sqly mysql_query("UPDATE userCake_Users SET `Banned`='1' WHERE `Username`='$to_ban'");
$sqlz mysql_query("UPDATE userCake_Users SET `BannedBy`='$banby' WHERE `Username`='$to_ban'");
}


legendary
Activity: 1540
Merit: 1000
November 27, 2013, 03:53:40 AM
#50
I'm bumping the coding thread Tongue I want to post up some more code here soon Cheesy
legendary
Activity: 1540
Merit: 1000
June 12, 2013, 10:28:57 AM
#49
lolz well I'll be selling my games for Bitcoin but I don't really approve of arcades, it's basically like purchasing a game with a hard coded time limit and that sucks Sad

Quote


    while (window.isOpen())
    {

    sf::Event event;
    while (window.pollEvent(event))

if ( event.type == sf::Event::MouseMoved );

{
    spritebutton.delete ( MouseMoved.x, MouseMoved.y );
}


{
 if (event.type == sf::Event::Closed)
 window.close();
}


I WILL CODE A WORKING BUTTON OR DIE TRYING!
hero member
Activity: 686
Merit: 504
always the student, never the master.
June 12, 2013, 09:25:15 AM
#48
You guys who are into game programming may like this, did some digging around and found this website http://code.google.com/p/gqe/, a lot of the sites are completely outdated but it looks this one at least has some 2.0 code, I downloaded pong to get me going! Smiley

someone should make a bit arcade. instead of depositing 50 cents per play, you deposit .005 bitcoins or something
legendary
Activity: 1540
Merit: 1000
June 11, 2013, 08:07:20 AM
#47
You guys who are into game programming may like this, did some digging around and found this website http://code.google.com/p/gqe/, a lot of the sites are completely outdated but it looks this one at least has some 2.0 code, I downloaded pong to get me going! Smiley
legendary
Activity: 1078
Merit: 1003
June 04, 2013, 12:24:22 AM
#46
uAWR s0 l33t

People, please, hold your applause.

Code:
def myNewFunction(x):
    if x > 1:
        return x + 1
    else:
        return 0

print myNewFunction(int(raw_input()))

It took me three weeks to figure out how many parenthesis should go on the end of the last statement, but due to my unwavering perseverance, I've made a program that...probably cures computer cancer or something.  But anyway, I think I'm ready to make the next World of Warcraft clone.
hero member
Activity: 686
Merit: 504
always the student, never the master.
June 03, 2013, 06:50:43 AM
#45
Quote


#include
#include
#include

int main()
{

    sf::RenderWindow window(sf::VideoMode(800, 600), "test");

sf::CircleShape shape ( 50 );
shape.setFillColor( sf::Color::White );

    while (window.isOpen())
    {

    sf::Event event;
    while (window.pollEvent(event))

        {
           if (sf::Mouse::isButtonPressed ( sf::Mouse::Left ) )

           shape.setPosition ( sf::Mouse::getPosition( window ).x , sf::Mouse::getPosition( window ).y  );

        }



{
 if (event.type == sf::Event::Closed)
 window.close();
}

        window.clear();
        window.draw ( shape );
        window.display();

    }

    return 0;


I managed to partially fix my code yet again to make it almost functional, turns out, keeping mouse events outside of the brackets where you're having your objects interact with the mouse/keyboard royally fucks things up if you're not careful, now I just need to figure out why my shape is terrified of my mouse cursor and get this code working with the move command.

Oh and never forget, x and y always, never y and x Cheesy

Hell yeah bro! i fixed my php script to. turned out i did need to fclose the file like jackjack said. for some strange reason notepad++ doesn't highlight the syntax of fclose so i thought i was doing something wrong. showing zero errors on E_ALL i can sleep soundly now.
legendary
Activity: 1540
Merit: 1000
June 03, 2013, 06:37:19 AM
#44
Quote


#include
#include
#include

int main()
{

    sf::RenderWindow window(sf::VideoMode(800, 600), "test");

sf::CircleShape shape ( 50 );
shape.setFillColor( sf::Color::White );

    while (window.isOpen())
    {

    sf::Event event;
    while (window.pollEvent(event))

        {
           if (sf::Mouse::isButtonPressed ( sf::Mouse::Left ) )

           shape.setPosition ( sf::Mouse::getPosition( window ).x , sf::Mouse::getPosition( window ).y  );

        }



{
 if (event.type == sf::Event::Closed)
 window.close();
}

        window.clear();
        window.draw ( shape );
        window.display();

    }

    return 0;


I managed to partially fix my code yet again to make it almost functional, turns out, keeping mouse events outside of the brackets where you're having your objects interact with the mouse/keyboard royally fucks things up if you're not careful, now I just need to figure out why my shape is terrified of my mouse cursor and get this code working with the move command.

Oh and never forget, x and y always, never y and x Cheesy
hero member
Activity: 686
Merit: 504
always the student, never the master.
June 03, 2013, 05:19:21 AM
#43
Pussy! Tongue

Okay okay.  I'll keep trying.

Code:
def conjunctionJunction():
    print "What's your function?"

conjunctionJunction()

uAWR s0 l33t
legendary
Activity: 1078
Merit: 1003
June 03, 2013, 05:02:12 AM
#42
Pussy! Tongue

Okay okay.  I'll keep trying.

Code:
def conjunctionJunction():
    print "What's your function?"

conjunctionJunction()
legendary
Activity: 1540
Merit: 1000
June 03, 2013, 04:56:35 AM
#41
Code:
print "Hello, world!"

Phew, I need to take a break.

Pussy! Tongue
hero member
Activity: 686
Merit: 504
always the student, never the master.
June 03, 2013, 04:55:47 AM
#40
  • email+url: look at regex
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*

  • you don't fclose

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:

Code:

'.$error.'
'; ?>  
'.$accept.'
'; ?>



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 ...
legendary
Activity: 1176
Merit: 1280
May Bitcoin be touched by his Noodly Appendage
June 03, 2013, 04:39:56 AM
#39
  • email+url: look at regex
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*

  • you don't fclose

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:

Code:

'.$error.'
'; ?> 
'.$accept.'
'; ?>



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.
hero member
Activity: 686
Merit: 504
always the student, never the master.
June 03, 2013, 04:30:23 AM
#38
  • email+url: look at regex
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*

  • you don't fclose

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:

Code:

'.$error.'
'; ?>  
'.$accept.'
'; ?>


legendary
Activity: 1078
Merit: 1003
June 03, 2013, 04:29:50 AM
#37
Code:
print "Hello, world!"

Phew, I need to take a break.
legendary
Activity: 1540
Merit: 1000
June 03, 2013, 04:27:04 AM
#36
yey! more people posting their code other than me! Cheesy
legendary
Activity: 1176
Merit: 1280
May Bitcoin be touched by his Noodly Appendage
June 03, 2013, 04:22:36 AM
#35
  • email+url: look at regex
  • you don't fclose
  • I don't see any echo so how can you display error or accept?
hero member
Activity: 686
Merit: 504
always the student, never the master.
June 03, 2013, 04:16:42 AM
#34
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
Code:
$email
and
Code:
$url
for common elements of emails and urls for example "@" and "http://" .also wierdly it displays the
Code:
$accept
div when i load the page, when it should display either the
Code:
$error
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.


Code:
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.
legendary
Activity: 1540
Merit: 1000
June 03, 2013, 04:06:09 AM
#33
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.

Quote

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

legendary
Activity: 1540
Merit: 1000
June 02, 2013, 12:31:50 PM
#32
I found out in an old post finally how to do it

Correct snytax is:

Quote

    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.
legendary
Activity: 1540
Merit: 1000
June 01, 2013, 08:03:00 AM
#31
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.

Quote


    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();
            }

legendary
Activity: 1176
Merit: 1280
May Bitcoin be touched by his Noodly Appendage
May 27, 2013, 07:54:34 AM
#30
Same happened for me
I never managed to get SDL working even for small tasks whereas SFML is a pleasure to use
legendary
Activity: 1540
Merit: 1000
May 27, 2013, 05:20:35 AM
#29
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.

Quote


#include

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;
}


legendary
Activity: 1540
Merit: 1000
May 19, 2013, 05:53:37 AM
#28
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.

Quote

#ifdef __cplusplus
    #include
#else
    #include
#endif

#include

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.
legendary
Activity: 1540
Merit: 1000
May 19, 2013, 05:41:53 AM
#27
Alright, thanks for the help, I'll steamroll through this like I've been doing with OpenGL Tongue just need to put the time in.
legendary
Activity: 4494
Merit: 3178
Vile Vixen and Miss Bitcointalk 2021-2023
May 19, 2013, 05:39:47 AM
#26
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! Tongue 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.

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! Cheesy
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.
legendary
Activity: 1540
Merit: 1000
May 19, 2013, 04:49:22 AM
#25
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! Tongue 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! Cheesy
legendary
Activity: 4494
Merit: 3178
Vile Vixen and Miss Bitcointalk 2021-2023
May 19, 2013, 01:24:12 AM
#24
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;".
legendary
Activity: 1540
Merit: 1000
May 18, 2013, 03:19:58 PM
#23
Quote

#ifdef __cplusplus
    #include
#else
    #include
#endif

#include

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.

Quote

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.
legendary
Activity: 1540
Merit: 1000
May 18, 2013, 06:28:41 AM
#22
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/
legendary
Activity: 1540
Merit: 1000
May 17, 2013, 06:33:03 PM
#21
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 Cheesy

Now I can begin work on my keyboard and mouse interaction Cheesy
staff
Activity: 3290
Merit: 4114
May 17, 2013, 01:50:09 PM
#20
print("We want a sub-forum")
user_input = input("What do you say staff?")
legendary
Activity: 1540
Merit: 1000
May 17, 2013, 01:00:39 PM
#19
Does anyone know of any up to date syntax for GLFW keyboard and mouse input? Or would you recommend something else? I'm searching around but I think I could use some help on this one.
legendary
Activity: 1540
Merit: 1000
May 16, 2013, 09:48:06 PM
#18
Quote
           
            glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
            glClear (GL_COLOR_BUFFER_BIT);

            glPushMatrix ();
            glTranslatef (-0.2f, 0.0f, 0.0f);
            glRotatef(theta, 0.0f, 1.0f, 0.0f);
            glBegin (GL_QUADS);
  
                              
                              glVertex3f (0.0f, -0.1f, 0.0f);
                              glVertex3f (-0.1f, 0.0f, 0.0f);
                              glVertex3f (0.0f, 0.1f, 0.0f);
                              glVertex3f (0.1f, 0.0f, 0.0f);
            glEnd ();
            glPopMatrix ();
            
            glPushMatrix ();
            glTranslatef (0.1f, 0.0f, 0.0f);
            glRotatef(theta, 0.0f, 1.0f, 0.0f);
            
            glBegin (GL_QUADS);

                              
                              glVertex3f (0.0f, -0.1f, 0.0f);
                              glVertex3f (-0.1f, 0.0f, 0.0f);
                              glVertex3f (0.0f, 0.1f, 0.0f);
                              glVertex3f (0.1f, 0.0f, 0.0f);
                              
            glEnd ();
            glPopMatrix ();

            SwapBuffers (hDC);

            theta += 1.0f;
            Sleep (1);
        }
    }


Must make it so I can click and drag these spinning squares Cheesy
legendary
Activity: 1540
Merit: 1000
May 16, 2013, 11:34:08 AM
#17
legendary
Activity: 1540
Merit: 1000
May 16, 2013, 11:24:46 AM
#16
Bah, does anyone know some good tutorials that show you how to combine OpenGL and C++ while I'm searching for them myself? The OpenGL tutorials are great and I have an easy time drawing basic stuff on it now but I need to look up how to properly combine everything so I can interact with the shapes I make Cheesy
newbie
Activity: 56
Merit: 0
May 15, 2013, 06:53:29 PM
#15
Nobody here's programming in LOLcode?  Seriously?  You should all try it.

Wikipedia: http://en.wikipedia.org/wiki/LOLCODE

The Hello World program:

HAI
CAN HAS STDIO?
VISIBLE "HAI WORLD!"
KTHXBYE


As you can see, its insane efficiency at any task combined with its extreme brevity makes it a must for any real coding project.
legendary
Activity: 1540
Merit: 1000
May 15, 2013, 05:58:48 PM
#14
Lets spam code all over this thread so the mods know there's demand for a category lolollool Cheesy
staff
Activity: 3290
Merit: 4114
May 15, 2013, 05:56:41 PM
#13
It would be really great if this got added as a sub-forum. I know it can be related to services etc.
But, this just seems like a great way to break it up from the other things located in other sections, however I don't have anything to add at this moment as i'm mainly a python programmer, and learning java now.
legendary
Activity: 1540
Merit: 1000
May 15, 2013, 05:40:05 PM
#12
Hmm, does anyone know of any good examples or tutorials for Codeblocks that show you how to code interaction with the shapes you make?

I may have just found what I needed Cheesy just needed to look for a bit longer.

http://www.codeproject.com/Articles/27219/TetroGL-An-OpenGL-Game-Tutorial-in-C-for-Win32-Pla
legendary
Activity: 1540
Merit: 1000
May 15, 2013, 05:21:56 AM
#11
I dunno about that, I don't think I want to use anything particularly pre-made I think the only thing I've done that's pre-made so far is use the Codeblocks OpenGL sample to get all the window setup that I need because the tutorials I've looked at are outdated with some of the stuff they have. I did notice some VK commands for all the keyboard stuff in the compiler so I'll have to have a look at the syntax involved with that so I can make stuff move.

Edit: AHA! Nehe seems to be very good with this stuff and it's just what I need, IF commands ftw! Cheesy
legendary
Activity: 3598
Merit: 2386
Viva Ut Vivas
May 15, 2013, 12:32:05 AM
#10
Have to admit, I think I'm starting to really enjoy messing around in OpenGL Cheesy I just need to figure out how to make it interactive.

I did some coding in OpenGL, it is pretty fun. I had to open up some of my old math books from college that I figured I would never need again.

For interaction, you should first start with using a key listener. Making stuff happen based upon various keyboard keys is fairly easy.
full member
Activity: 182
Merit: 100
May 14, 2013, 11:52:17 PM
#9
Just remember it's not the language that matters (okay, maybe it matters a little), it's the practices and techniques you learn from using that language. If you master the correct techniques, you'll pick up future languages faster, and produce better code and documentation.
legendary
Activity: 1540
Merit: 1000
May 14, 2013, 02:44:16 PM
#8
Have to admit, I think I'm starting to really enjoy messing around in OpenGL Cheesy I just need to figure out how to make it interactive.

Quote
             glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            glClear(GL_COLOR_BUFFER_BIT);

            glLoadIdentity();
            glPushMatrix();
            glTranslatef(-1.0f, -1.0f, 0.0f);
            glPushMatrix();
            glRotatef (90.0f, -180.0f, 0.0f, 0.0f);
            glPopMatrix();

                                            glBegin(GL_TRIANGLES);




                                            glVertex3f(0.5f, 0.5f, 0.0f);   glColor3f(2.0f, 0.5f, -1.0f);
                                            glVertex3f(1.5f, 0.5f, 0.0f);   glColor3f(1.0f, 0.5f, -1.0f);
                                            glVertex3f(0.5f, 1.0f, 0.0f);   glColor3f(6.0f, 0.5f, -1.0f);

                                            glVertex3f(0.5f, 1.0f, 0.0f);   glColor3f(1.0f, 0.5f, -1.0f);
                                            glVertex3f(1.5f, 0.5f, 0.0f);   glColor3f(2.0f, 0.5f, 1.0f);
                                            glVertex3f(1.5f, 1.0f, 0.0f);   glColor3f(1.0f, 0.5f, 1.0f);

                                            glVertex3f(0.5f, 1.0f, 0.0f);   glColor3f(1.0f, 0.5f, 1.0f);
                                            glVertex3f(1.5f, 1.0f, 0.0f);   glColor3f(1.0f, 0.5f, 1.0f);
                                            glVertex3f(1.0f, 1.5f, 0.0f);   glColor3f(1.0f, 0.5f, 1.0f);



            glEnd();

            glPopMatrix();


Coding spam woopeee! Cheesy
legendary
Activity: 1904
Merit: 1037
Trusted Bitcoiner
May 12, 2013, 10:38:35 PM
#7
i can do the job 2 of 3 ways;

Cheap, Fast, Good

if you want it:
Cheap & Fast,  fine, but it won't be very good.. (Dirty Code! lol )
Good & Cheap, ok, ill do my best!
Good & Fast,    sure, but thats not going to be cheap.  50,000BTC  Wink

 Tongue
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
May 12, 2013, 10:09:21 PM
#6
I would recommend reading Scott Meyers and Herb Sutter and keeping your focus on Standard C++ always (i.e. not extensions for specific compilers such as MSVC).

BTW - https://bitcointalksearch.org/topic/c-mentoring-203104.
full member
Activity: 182
Merit: 100
May 12, 2013, 03:20:32 PM
#5
I am interested in learning C++ mainly because that seems to be the most widely used language out there. I am already familiar with HTML because I've learned it some in school and have used it in creating my websites, and next year, I will be learning some Java as part of a course and will probably continue to mastery the following year. However, C++ I will need to learn by myself, so do you guys have any recommendations for me learning it by myself. My parents may help me as they both know C++ and multiple other coding languages.
legendary
Activity: 1176
Merit: 1280
May Bitcoin be touched by his Noodly Appendage
May 12, 2013, 09:52:28 AM
#4
I support a coding (sub-)FORUM
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
May 12, 2013, 09:34:30 AM
#3
Purely from a C++ coding style perspective I see no reason to be "indenting" the function calls you have (indenting is normally done for code *blocks* that are surrounded by braces or for conditional expressions).

You might consider using an "empty code block" to make it more express the indenting you are after though:

Code:
...
glPopMatrix();
{
   glBegin(GL_TRIANGLES);
   ...
   glEnd();
}

legendary
Activity: 826
Merit: 1002
amarha
May 12, 2013, 09:28:27 AM
#2
Nothing to add atm, but I support this idea for a thread.
legendary
Activity: 1540
Merit: 1000
May 12, 2013, 01:31:33 AM
#1
Considering there are clearly tons of programmers/learning programmers here I think we should make a thread where we can talk about different programming languages and help each other out, I'm currently messing around in OpenGL though I suspect if I want to make anything functional like a game I'm going to have to properly get into C++ too, feel free to post code here of stuff you're working on and need help with etc.


Quote


            glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            glClear(GL_COLOR_BUFFER_BIT);

            glLoadIdentity();
            glPushMatrix();
            glTranslatef(-0.5f, -0.5f, 0.0f);
            glPushMatrix();
            glRotatef (90.0f, -180.0f, 0.0f, 0.0f);
            glPopMatrix();

                                            glBegin(GL_TRIANGLES);




                                            glVertex3f(0.5f, 0.5f, 0.0f);   glColor3f(1.0f, 0.5f, 1.0f);
                                            glVertex3f(1.5f, 0.5f, 0.0f);   glColor3f(1.0f, 0.5f, 1.0f);
                                            glVertex3f(0.5f, 1.0f, 0.0f);   glColor3f(1.0f, 0.5f, 1.0f);

                                            glVertex3f(0.5f, 1.0f, 0.0f);   glColor3f(1.0f, 0.5f, 1.0f);
                                            glVertex3f(1.5f, 0.5f, 0.0f);   glColor3f(1.0f, 0.5f, 1.0f);
                                            glVertex3f(1.5f, 1.0f, 0.0f);   glColor3f(1.0f, 0.5f, 1.0f);

                                            glVertex3f(0.5f, 1.0f, 0.0f);   glColor3f(1.0f, 0.5f, 1.0f);
                                            glVertex3f(1.5f, 1.0f, 0.0f);   glColor3f(1.0f, 0.5f, 1.0f);
                                            glVertex3f(1.0f, 1.5f, 0.0f);   glColor3f(1.0f, 0.5f, 1.0f);



            glEnd();

            glPopMatrix();


I made a pink pentagon, WEEEEEEEEE! Cheesy Can't figure out how to get GLRotatef working though.
Jump to: