Thread: My C creations 4

  1. #1
    Registered User
    Join Date
    Jul 2017
    Posts
    9

    My C creations 4

    Here presenting to you all
    "The Good Fight".

    Here's the video enjoy it



    PS: The complete information about the game is in the description of the video in YouTube!.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    It's rather dull and boring without the source code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jul 2017
    Posts
    9
    Quote Originally Posted by Salem View Post
    It's rather dull and boring without the source code.
    Here's the source code in one file main.c

    main

    Thank you!.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    I notice that rayscont only ever increases. It would seem to me that the game would just get slower and slower as it worked it's way up to 500000 stored rays, and then crash.

    Some of your #defines should be enum's, like GOOD/EVIL and your direction constants.

    > for(;c<79;c++)printf("%c",219);
    You do this (or slight variations of it) a lot. Perhaps it needs it's own function.
    219 should be a #define'd constant (along with any other DOS graphics chars (eg, #define PLAYER_CHAR 2).
    Consider using putchar instead - using printf to output just one char is quite heavy.

    > printf("HP: %d%c",goodhp,37);
    You can simplify your if/else this with
    printf("HP: %2d%%",goodhp);

    > printf("%cYou are the only hope
    Do you know that " can be used to print double quotes inside double-quoted strings?

    > while(1)
    This should be say while(alive), and hopefully you can factor out your goto in the process.
    This loop is 200 or so lines long, so it needs to be split up somewhat.

    > int ps=0;
    Everywhere you use this, it's an if/else copy/paste code block.
    You ought to be able to handle this in a more generic way.



    We're missing
    #include "rlutil.h"
    and your audio file.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Jul 2017
    Posts
    9

    Red face

    Quote Originally Posted by Salem View Post
    I notice that rayscont only ever increases. It would seem to me that the game would just get slower and slower as it worked it's way up to 500000 stored rays, and then crash.

    Some of your #defines should be enum's, like GOOD/EVIL and your direction constants.

    > for(;c<79;c++)printf("%c",219);
    You do this (or slight variations of it) a lot. Perhaps it needs it's own function.
    219 should be a #define'd constant (along with any other DOS graphics chars (eg, #define PLAYER_CHAR 2).
    Consider using putchar instead - using printf to output just one char is quite heavy.

    > printf("HP: %d%c",goodhp,37);
    You can simplify your if/else this with
    printf("HP: %2d%%",goodhp);

    > printf("%cYou are the only hope
    Do you know that " can be used to print double quotes inside double-quoted strings?

    > while(1)
    This should be say while(alive), and hopefully you can factor out your goto in the process.
    This loop is 200 or so lines long, so it needs to be split up somewhat.

    > int ps=0;
    Everywhere you use this, it's an if/else copy/paste code block.
    You ought to be able to handle this in a more generic way.



    We're missing
    #include "rlutil.h"
    and your audio file.
    Oh thanks for the advices on how to make proper code for my programs. I really appreciate it!.

    I think i will be more careful the next time.

    Uhmmm...you can find rlutil here:
    GitHub - tapio/rlutil: C and C++ utilities for cross-platform console roguelike game creation.

    And about the audio file just delete that part in the code and it will compile with no problems.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My C creations 3
    By jeimyrm in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 07-13-2017, 12:02 AM
  2. My C creations 2
    By jeimyrm in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 07-13-2017, 12:00 AM
  3. My C creations 1
    By jeimyrm in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 07-12-2017, 11:58 PM

Tags for this Thread