Server Help

Non-Subspace Related Coding - File Creator

hellzlaker - Sun Dec 24, 2006 11:30 am
Post subject: File Creator
I made a simple program but its kind of usefull. You open it up and it and you type in what type of file you you want to create, and it creates that file to desktop..(RTF,CFG,CONF,HTML,INI,HLP) The reason i made this because a long time ago i had a trouble making help file for my zone (f1 function) so i decided to make a quick program that makes some files..I attached the program and the source =D
Mine GO BOOM - Sun Dec 24, 2006 12:14 pm
Post subject:
You really should look into C/C++ tutorials. What IDE are you using, because your executable is a debug-build, which makes it larger than it should be. When publishing any executable or library, use a release build, as the program will be smaller and faster.

A quick look over your code, you never return a value for main(). At the end of the function, because it is of type int, you should return a value. The default would be 0, which generally means the program exited normally.

So far, none of your programs do anything programming related. Look into building a program that calculates quadratic functions. Then try and do one that uses Newton's method to estimate answers to integrals. Look up on Wikipedia to learn programming algorithms to build your own sorting functions, like bubblesort, quicksort, and mergesort. Maybe try and learn a bit about pointers by making your own linked-list class. Then make it doubly linked (can go in reverse). Try a tree structure. Then a hash table.
hellzlaker - Sun Dec 24, 2006 12:25 pm
Post subject:
hm i dont really get what your saying but do you mean like program my own calculator that does extra stuff like
Code: Show/Hide
quadratic functions. Then try and do one that uses Newton's method to estimate answers to integrals. Look up on Wikipedia to learn programming algorithms to build your own sorting functions, like bubblesort, quicksort, and mergesort.
?
Doc Flabby - Sun Dec 24, 2006 12:32 pm
Post subject:
Quote:
So far, none of your programs do anything programming related. Look into building a program that calculates quadratic functions. Then try and do one that uses Newton's method to estimate answers to integrals. Look up on Wikipedia to learn programming algorithms to build your own sorting functions, like bubblesort, quicksort, and mergesort. Maybe try and learn a bit about pointers by making your own linked-list class. Then make it doubly linked (can go in reverse). Try a tree structure. Then a hash table.


I know that stuff is important but that kinda of thing never really simulated me in computing i found it boring. The thing that i enjoy from programming is the creative element. I like the whole creating things.

if you want a more creative challenge, a nice thing to start with is to make a simple game like pong or snake.

Sounds easy, but you can make it more complicated by adding AI for example in pong. Or for example in snake create a number of levels for the snake. On approach to making the level maps would be to create a map editor tongue.gif
Anonymous - Sun Dec 24, 2006 1:48 pm
Post subject:
Lol, it doesnt sound easy making a game snake or pong for me would be hard as f*ck. But its actually a cool idea =D
Animate Dreams - Sun Dec 24, 2006 2:52 pm
Post subject:
Actually, I agree. I don't profess to have any programming skill, but I DO have a working knowledge of basic C. Actually, I wouldn't even know where to start on Pong, I've never done anything graphical at all. Where do you start for something like that? I could always stand to learn more.
Cyan~Fire - Sun Dec 24, 2006 3:06 pm
Post subject:
You could either use the Windows GDI (no external libraries required but not the most efficient way to do graphics) or SDL. Both would be very easy, though SDL would require a little more knowledge of C/C++.
SamHughes - Sun Dec 24, 2006 10:54 pm
Post subject:
Mine GO BOOM wrote:
A quick look over your code, you never return a value for main(). At the end of the function, because it is of type int, you should return a value. The default would be 0, which generally means the program exited normally.


You don't need to explicitly return a value in the main function in C++.
hellzlaker - Mon Dec 25, 2006 10:02 am
Post subject:
SamHughes wrote:
[..]



You don't need to explicitly return a value in the main function in C++.



Yes because i looped with the
Code: Show/Hide
do{}while()
and I added into the do while function
Code: Show/Hide


int a=1;

do {
            if (){}
            else if(){}
            else if (value=="exit") { return 0;}
     }      while (a=1)




So have the exit function inside the do-while loop and no point of putting it outside since it will never exit the do-while loop.
Mine GO BOOM - Mon Dec 25, 2006 10:08 am
Post subject:
You do know, while (a=1) will set a to 1, then check that it is non zero? I'm assuming you'd actually would have wanted (a == 1). Instead of using a variable, you can just use do {} while (1);
Doc Flabby - Tue Dec 26, 2006 10:03 am
Post subject:
Cyan~Fire wrote:
You could either use the Windows GDI (no external libraries required but not the most efficient way to do graphics) or SDL. Both would be very easy, though SDL would require a little more knowledge of C/C++.


You wouldn't necessery even need to use any graphics libraries.
You could create the game using the console.

I've created this example of a ball bouncing around a console. It uses windows API functions. I created it using dev c++.

pong isnt very complex. The basics of pong ( a ball bouncing round a screen are demonstrated below). The trick is to start with something simple and then add to it. To start with i had no idea how to write a ball to the console where i wanted it. But found that out, then i had to work out how to set the screen size and remove the scroll bars. then it was a case of moving the ball, and erasing the trail it left be hind.

Code: Show/Hide

#include <windows.h>
int main(int argc, char *argv[ ], char *envp[ ] )
    {
     COORD ballposition;
     COORD oldballposition;
     DWORD dwWritten;
     CHAR chBuffer[256];
   
    //setup handle to STDout
       HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
   
    //size of screen
        SMALL_RECT rc = { 0, 0, 40, 20 };     
       
        BOOL bRet = SetConsoleWindowInfo(hStdout, TRUE, &rc);
    //size of buffer (removes scroll bars)
        if(bRet)
        {
            COORD cd = {
                41,
                21
            };
   
            bRet = SetConsoleScreenBufferSize(hStdout, cd);
        }
 
     //setup ball   
     //whats ball look like
     char Ball[]={"@"};
     char OldBall[]={" "};
     //inital direction
     int dx =1;
     int dy =1;
     //initial position
     oldballposition.X=9;
     oldballposition.Y=9;
     ballposition.X=10;
     ballposition.Y=5;
     
//extenstion would be to detect key presses to allow quitting
     while(1)
     {
         //move ball in direction
         ballposition.X=ballposition.X+dx;
         ballposition.Y=ballposition.Y+dy;
         
         //sleep (contols speed
         Sleep(20);
         
          //erase the ball from screen
         SetConsoleCursorPosition(hStdout, oldballposition);
         WriteFile(hStdout, OldBall, sizeof(OldBall), &dwWritten, NULL);
         
         //print ball to screen
         SetConsoleCursorPosition(hStdout, ballposition);
         WriteFile(hStdout, Ball, sizeof(Ball), &dwWritten, NULL);
         
         //change ball direction if we hit wall
         
         if (ballposition.X > 39)
         {
           dx = -dx;
         }
          if (ballposition.X < 1)
         {
           dx= -dx;
         }
          if (ballposition.Y >19)
         {
           dy = -dy;
         }
          if (ballposition.Y < 1)
         {
           dy = -dy;
         }
         //set position of where ball was
         oldballposition = ballposition   ;     
       
    }

    //close and tidy (never reached lol)
    CloseHandle(hStdout) ;   
}


This is probably the longest c/c++ program i have ever written lol.
Bak - Tue Dec 26, 2006 10:45 am
Post subject:
Code: Show/Hide
else if (value =="exit")
        {
             cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
             cout<<"                       A3 is shitting down..\a";
             cout<<"\n                              |10%     |";
             Sleep(250);
             cout<<"\n                              |50%     |  ";
             Sleep(250);
             cout<<"\n                              |100%    |   ";
             cout<<"\n                              |Good Bye|\n\n\n\n";
             Sleep(750);
             return 0;
        }
lol
Cyan~Fire - Tue Dec 26, 2006 12:11 pm
Post subject:
Code: Show/Hide
/* Source Code Windows 2000 */

#include "win31.h"
#include "win95.h"
#include "win98.h"
#include "workst~1.h"
#include "evenmore.h"
#include "oldstuff.h"
#include "billrulz.h"
#include "monopoly.h"
#include "backdoor.h"
#define INSTALL HARD

char make_prog_look_big(16000000);
void main()
{
  while(!CRASHED)
  {
    display_copyright_message();
    display_bill_rules_message();
    do_nothing_loop();

    if (first_time_installation)
      {
      make_100_megabyte_swapfile();
      do_nothing_loop();
      totally_screw_up_HPFS_file_system();
      search_and_destroy_the_rest_of-OS2();
      make_futile_attempt_to_damage_Linux();
      disable_Netscape();
      disable_RealPlayer();
      disable_Lotus_Products();
      hang_system();
      } //if
    write_something(anything);
    display_copyright_message();
    do_nothing_loop();
    do_some_stuff();

    if (still_not_crashed)
    {
    display_copyright_message();
    do_nothing_loop();
    basically_run_windows_31();
    do_nothing_loop();
    } // if
  } //while

  if (detect_cache())
    disable_cache();

  if (fast_cpu())
    {
    set_wait_states(lots);
    set_mouse(speed,very_slow);
    set_mouse(action,jumpy);
    set_mouse(reaction,sometimes);
    } //if

  /* printf("Welcome to Windows 3.1");    */
  /* printf("Welcome to Windows 3.11");   */
  /* printf("Welcome to Windows 95");     */
  /* printf("Welcome to Windows NT 3.0"); */
  /* printf("Welcome to Windows 98");     */
  /* printf("Welcome to Windows NT 4.0"); */
  printf("Welcome to Windows 2000");

  if (system_ok())
    crash(to_dos_prompt)
  else
    system_memory = open("a:\swp0001.swp",O_CREATE);

  while(something)
    {
    sleep(5);
    get_user_input();
    sleep(5);
    act_on_user_input();
    sleep(5);
    } // while
  create_general_protection_fault();

} // main

Doc Flabby - Tue Dec 26, 2006 2:21 pm
Post subject:
BADP.gif
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group