remember the guy .......

Discussion in 'Wii - Hacking' started by arjaylight, Sep 15, 2010.

Sep 15, 2010

remember the guy ....... by arjaylight at 7:10 AM (2,652 Views / 0 Likes) 20 replies

  1. arjaylight
    OP

    Newcomer arjaylight Advanced Member

    Joined:
    Jun 17, 2009
    Messages:
    65
    Country:
    Philippines
    i believe || is short-circuit "OR" while | is the regular "OR"

    || is better (i think) because once it found a true value, it will automatically do the statement body and skips other conditions.
     


  2. scooby74029

    Member scooby74029 "fake coder"

    Joined:
    May 7, 2010
    Messages:
    1,174
    Location:
    oklahoma, USA
    Country:
    United States
    it was me scooby

    so i have been studying c++ as much as i have time for.
    it has been about 2 and a half months since i started.

    i have a stupid game i have been struggling with and would like some feedback.
    i'll post link to game (for windows)and source too.
    http://www.mediafire.com/?byg4q7uq98ks03g
     
  3. giantpune

    Member giantpune GBAtemp Addict

    Joined:
    Apr 10, 2009
    Messages:
    2,860
    Country:
    United States
    i didnt play it since it is windows game, but i took a quick look at main.cpp. you use
    Code:
    else if((answer==1)|(answer==2))
    many times. do you mean "||" ? there are different "or"... "|" and "||" mean different things.


    and when you get the person's name, you use
    Code:
    char name[15];
    im not sure how the memory nanny in windows is, but what happens when you enter a name that is too long? i think you may fill up the buffer like the twilight hack did and maybe run into trouble.
     
  4. scooby74029

    Member scooby74029 "fake coder"

    Joined:
    May 7, 2010
    Messages:
    1,174
    Location:
    oklahoma, USA
    Country:
    United States
    bump:

    well i hope at least one person will respond.
     
  5. scooby74029

    Member scooby74029 "fake coder"

    Joined:
    May 7, 2010
    Messages:
    1,174
    Location:
    oklahoma, USA
    Country:
    United States
    i know still tring to figure out which case i need to use?
     
  6. Joe88

    Member Joe88 [λ]

    Joined:
    Jan 6, 2008
    Messages:
    11,187
    Location:
    NYC
    Country:
    United States
    your using inclusive or, your should be using regular boolean logic or ( || )
     
  7. scooby74029

    Member scooby74029 "fake coder"

    Joined:
    May 7, 2010
    Messages:
    1,174
    Location:
    oklahoma, USA
    Country:
    United States
    so the first one means or literally ?

    | ||
     
  8. Joe88

    Member Joe88 [λ]

    Joined:
    Jan 6, 2008
    Messages:
    11,187
    Location:
    NYC
    Country:
    United States
  9. arasium

    Member arasium GBAtemp Regular

    Joined:
    Mar 19, 2009
    Messages:
    187
    Location:
    Paris
    Country:
    France
    The real difference between | and || is that this first one is a bit operation and the second one is a logical operation.


    In fact, in c/c++, a statement is true when the result is different from 0. So when you use ==, the program is doing something like that:

    int is_equals(int a, int b) wich return 0 if not equal.

    So when you use |, the result will be a bitwise OR and if one of the operand is different from 0, the result will be different from 0 => If one of the operand is "true" the result will be "true". So, the program will run perfectly.

    But like someone said, it's better to use ||, because using that, the program won't do the same. He will check the second value only if the first is "false". In ASM, you will have a pseudo code like that:

    if(a || b) =>

    Code:
    IF a != 0
    ÂÂGOTO EXEC
    
    IF b != 0
    ÂÂÂÂGOTO EXEC
    
    GOTO ENDIF
    
    EXEC:
    ÂÂyour code
    
    ENDIF:
    ÂÂthe rest of the prog
    And with if( a | b) =>

    Code:
    C = A | B
    IF C == 0
    ÂÂGOTO ENDIF
    
    your code
    
    ENDIF:
    ÂÂthe rest of your code
     
  10. Wiimm

    Member Wiimm Developer

    Joined:
    Aug 11, 2009
    Messages:
    2,051
    Location:
    Germany
    Country:
    Germany
    Use tables, parameters and return values. Using to much global parameters make the code confusing and incluides side effects. For example I have rewritten ques_toons():

    Warning: Spoilers inside!
     
  11. cracker

    Member cracker Nyah!

    Joined:
    Aug 24, 2005
    Messages:
    3,132
    Country:
    United States
     
  12. SanGor

    Member SanGor Witchhunter

    Joined:
    Aug 21, 2008
    Messages:
    993
    Country:
    United States
    Alot of the code you have written could be coded simplier in the way people have already pointed out but I wanted to say on addtional thing, don't put function into header files as they directly inserted into the file which includes them so this will sooner or later cause you some trouble.

    Also the idea of functions is to minimize code in cases some job has to be done more than once or with different values, making a function for a something which is just done once or just a few lines of static code isn't worth to be made a function. ( open() and open2() for example ).

    It's also a good idea to keep the main.cpp simple, best would be only having the main() function in there.

    I would use a 2D/3D array fo the questions/answers and I would do it like that:




    CODEÂÂÂÂÂÂÂÂ...

    ÂÂÂÂÂÂÂÂ#define MAX_QUESTIONS 2

    ÂÂÂÂÂÂÂÂint select, answer;

    ÂÂÂÂÂÂÂÂcin >> select;

    ÂÂÂÂÂÂÂÂif( select >= MAX_QUESTIONS )
    ÂÂÂÂÂÂÂÂÂÂÂÂfail();

    ÂÂÂÂÂÂÂÂint CurrentQuestion=0;

    ÂÂÂÂÂÂÂÂchar *Questions[2][2] = {
    ÂÂÂÂÂÂÂÂÂÂÂÂ{
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ"Who?",
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ"Where?",
    ÂÂÂÂÂÂÂÂÂÂÂÂ},
    ÂÂÂÂÂÂÂÂÂÂÂÂ{
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ"When?",
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ"Why?",
    ÂÂÂÂÂÂÂÂÂÂÂÂ},

    ÂÂÂÂÂÂÂÂ};

    ÂÂÂÂÂÂÂÂchar *Answers[2][2][2] = {
    ÂÂÂÂÂÂÂÂÂÂÂÂ{
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ{
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ"1. He",
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ"2. She",
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ},
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ{
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ"1. There",
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ"2. Here",
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ},
    ÂÂÂÂÂÂÂÂÂÂÂÂ},
    ÂÂÂÂÂÂÂÂÂÂÂÂ{
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ{
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ"1. Now",
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ"2. Later",
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ},
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ{
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ"1. Love",
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ"2. Money",
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ},
    ÂÂÂÂÂÂÂÂÂÂÂÂ},

    ÂÂÂÂÂÂÂÂ};


    ÂÂÂÂÂÂÂÂwhile( CurrentQuestion < MAX_QUESTIONS )
    ÂÂÂÂÂÂÂÂ{
    ÂÂÂÂÂÂÂÂÂÂÂÂcout answer;
    ÂÂÂÂÂÂÂÂÂÂÂÂDoCheck( select, answer );
    ÂÂÂÂÂÂÂÂ}
     
  13. scooby74029

    Member scooby74029 "fake coder"

    Joined:
    May 7, 2010
    Messages:
    1,174
    Location:
    oklahoma, USA
    Country:
    United States
    thanks for all of your help and the rewrites guys

    i know i did somethings wrong but i have only gotten throught the first 5 chapters of this tutorial
    http://www.cprogramming.com/tutorial/lesson1wrap.html

    really again thanks for the help and i will reread this after work and start a rewrite soon

    by the way if i knew more how to make structures and more about functions and arrays my game probly would not have been
    so long. also if someone has the time to rewrite it properly i would like to see the proper way to do it

    i mean with defines and functions that do something and return something. i couldnt find any small programs on the next to study how these things are put together.

    well again thanks everyone
     
  14. cracker

    Member cracker Nyah!

    Joined:
    Aug 24, 2005
    Messages:
    3,132
    Country:
    United States
    Here's my version of the slimmed down source. For loading/saving scores I prefer fopen instead of iostream (haven't worked with it much I will admit) and can show you the code with that method if you want.
     
  15. scooby74029

    Member scooby74029 "fake coder"

    Joined:
    May 7, 2010
    Messages:
    1,174
    Location:
    oklahoma, USA
    Country:
    United States
    bump:


    hoping someone was on who might have time to help me out. i would like someone to take my program and rewrite it.

    i am only just begining to learn so all i want is some functions that take args and return something so i can see how it is set up.

    i guess i am not getting it...well all of it.

    like i said earlier i am only 2 months into learning from a website. i am only up to switchcase and pointers now and still dont know how to use them very well as you will see in my program.
     
  16. scooby74029

    Member scooby74029 "fake coder"

    Joined:
    May 7, 2010
    Messages:
    1,174
    Location:
    oklahoma, USA
    Country:
    United States
    awsome thanks big thanks @cracker ill download it now
     
  17. scooby74029

    Member scooby74029 "fake coder"

    Joined:
    May 7, 2010
    Messages:
    1,174
    Location:
    oklahoma, USA
    Country:
    United States
    well i looked over what cracker posted and all i can say is man mine was pooo compared to that.....

    thanks alot cracker i will use it as an example for what ever i try next.

    if anyone else would like to help me understand how to code efficiently and effectively.......
    please send to me or post here or you can take the other cpp files and show me some suff with them.
    i just want to learn.

    thanks in advance to all helping.

    and if this is not on topic please tell me where to go and i will and if admin would delete from here and put where it suppose to go
    if they can?...idk new to most of this. i still hunt and peck at keyboard never learned to type until recently..
    learning that too.....
     
  18. Joe88

    Member Joe88 [λ]

    Joined:
    Jan 6, 2008
    Messages:
    11,187
    Location:
    NYC
    Country:
    United States
    I did make a 2 player tic tac toe game if you wanna look at that

    a few other things like a gas pump emulator
     
  19. scooby74029

    Member scooby74029 "fake coder"

    Joined:
    May 7, 2010
    Messages:
    1,174
    Location:
    oklahoma, USA
    Country:
    United States
    @joe88

    yes i would like to see them

    can you post them or send them to my email
     
  20. Joe88

    Member Joe88 [λ]

    Joined:
    Jan 6, 2008
    Messages:
    11,187
    Location:
    NYC
    Country:
    United States

Share This Page