QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

First c experience (fixed)

This is a discussion on First c experience (fixed) within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; This is the first program I made in C. It is a little game and I´m posting to get tips ...

Reply
 
LinkBack Thread Tools
Old 08-09-2007, 08:03 AM   #1
 
Join Date: Apr 2007
Posts: 21
Trader Feedback: 0
Default First c experience (fixed)

This is the first program I made in C.

It is a little game and I´m posting to get tips from the veterans. It still has a lot to be done but I´m posting now that the structure is done so if there any change to be made, better do it earlier.
My previous experience was mostly on pascal and I made this based only on the psp-programming tutoriais. I have some php experience that helped too.

The objective of the game would be the only color remaining, it is kinda intuitive so I won´t explain here.

I put some comments on the code so the veterans will grasp it easier. I think it´s is easy enough for others begginers to study also. I´m accepting any hint or constructive criticism.

What I´m planning next (in order):
A.I. for the computer (play alone is boring)
PNG´s instead of drawing.
Some sound to make marrier.
Learn how use fonts
Multiplayer adhoc (I´m dreaming here but since I will need for my next homebrew ideas better work to learn it)


(Sorry if some sentences didn´t make sense, english isn´t my native language)
Attached Files
File Type: rar main.rar‎ (4.7 KB, 6 views)

Last edited by petervaz; 08-09-2007 at 08:38 AM.. Reason: this was the intended post
petervaz is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-09-2007, 08:04 AM   #2
Banned for LIFE
 
Join Date: Oct 2006
Location: East London, England
Posts: 2
Trader Feedback: 0
Default

erm. what?
eldiablov is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-09-2007, 08:04 AM   #3
 
Join Date: Jul 2006
Location: NorCal
Posts: 24,900
Trader Feedback: 0
Default

Exactly what is it and why do you need us to compile it?
__________________
If you ever need me, you can contact me at [URL="**********.net"]**********.net.[/URL]
Adiuvo is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-09-2007, 08:05 AM   #4
Banned for LIFE
 
Join Date: Oct 2006
Location: East London, England
Posts: 2
Trader Feedback: 0
Default

where are you getting the idea that he needs something compiling ? I see no attachment. At all ...
eldiablov is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-09-2007, 08:14 AM   #5
 
Join Date: Jul 2006
Location: NorCal
Posts: 24,900
Trader Feedback: 0
Default

Quote:
Originally Posted by eldiablov
where are you getting the idea that he needs something compiling ? I see no attachment. At all ...
This was it.
__________________
If you ever need me, you can contact me at [URL="**********.net"]**********.net.[/URL]
Adiuvo is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-09-2007, 08:16 AM   #6
 
Join Date: Jul 2007
Posts: 296
Trader Feedback: 0
Default

This is whole "I'm to lazy to set up my compiler, so will you plzzz compile it for me????" needs to stop. QJ should ban as it truly is a request.
_dysfunctional is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-09-2007, 08:21 AM   #7
Banned for LIFE
 
Join Date: Oct 2006
Location: East London, England
Posts: 2
Trader Feedback: 0
Default

Adiuvo, thats weird i got a qj attachment error message

_dysfunctional is totally right. it causes mess in the development forum and is an annoyance.

Im sorry but if you cant setup your own compiler then with regret. You're on your own. sorry.
eldiablov is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-09-2007, 08:24 AM   #8
 
Join Date: Apr 2007
Posts: 21
Trader Feedback: 0
Default

Err, sorry about that.
I slipped the enter key when starting to make the post and did this mess.
Not the best first impression, i suppose.
petervaz is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-09-2007, 08:25 AM   #9
Banned for LIFE
 
Join Date: Oct 2006
Location: East London, England
Posts: 2
Trader Feedback: 0
Default

petervaz, go to psp-programming.com and click on tutorials

They will give you what you need to get started
eldiablov is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-09-2007, 08:34 AM   #10
 
myschoo's Avatar
 
Join Date: Jul 2006
Location: Middle Europe
Posts: 1,281
Trader Feedback: 0
Default

attachment doesnt work btw.

Invalid Attachment specified. If you followed a valid link, please notify the administrator
__________________
[CENTER][SIZE="1"][1 Year QJ Member]
[COLOR="Sienna"][LUA Coder and C Learner][/COLOR]
[URL="http://dl.qj.net/Ball-Revamped-Clone-v.1-PSP-Homebrew-Games/pg/12/fid/15231/catid/195"] [COLOR="SlateGray"][Ball Revamped Clone v0.1][/COLOR] [/URL]
[URL="http://dl.qj.net/Phil-s-Shooting-Range-v0.3-PSP-Homebrew-Games/pg/12/fid/11542/catid/194"] [COLOR="SlateGray"][Phil's Shooting Range v0.3][/COLOR] [/URL]
[URL="http://dl.qj.net/Organization-Apps/pg/12/fid/14248/catid/190"][COLOR="SlateGray"][HideFile PRX v2][/COLOR][/URL]
[URL="http://dl.qj.net/SSR-PRX-v1.1-PSP-Homebrew-Applications/pg/12/fid/14725/catid/151"][COLOR="SlateGray"][SSR PRX v1.1][/COLOR][/URL] [/SIZE][/CENTER]
myschoo is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-09-2007, 08:58 AM   #11
 
Join Date: Jul 2007
Posts: 296
Trader Feedback: 0
Default

Just a few pet peeves. You use a lot of global variables rather than passing variables as an argument, and you use a lot of underscores in your variable names.
_dysfunctional is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-09-2007, 09:46 AM   #12
 
 
My Mood: Bored
Join Date: Apr 2006
Location: England ~¦¦¦|+|¦¦¦~
Posts: 1,112
Trader Feedback: 0
Default

Quote:
Originally Posted by _dysfunctional
Just a few pet peeves. You use a lot of global variables rather than passing variables as an argument, and you use a lot of underscores in your variable names.
You use an underscore in you NAME Whats wrong with using underscores?
__________________
...Just Returned To The Scene...
JaSo PsP is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-09-2007, 09:47 AM   #13
 
Join Date: Mar 2007
Posts: 755
Trader Feedback: 0
Default

Quote:
Originally Posted by _dysfunctional
This is whole "I'm to lazy to set up my compiler, so will you plzzz compile it for me????" needs to stop. QJ should ban as it truly is a request.
he never asked anything to be compiled, he asked if some more experienced coders could look at his code and give some helpful hints or constructive criticism

edit: did he ask it to be compiled before he edited it?
__________________
[I][U]QJ took away my sig. :([/U][/I]
michaelp is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-09-2007, 09:48 AM   #14
 
Join Date: Jul 2007
Posts: 296
Trader Feedback: 0
Default

Code:
int this_is_the_variable_for_my_x_axis_and_btw_underscores_suck;
int thisIsTheVariableForMyXAxisAndBtwUnderscoresSuck;
Much easier to type.
_dysfunctional is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-09-2007, 10:05 AM   #15
 
Join Date: Apr 2007
Posts: 21
Trader Feedback: 0
Default

Quote:
Originally Posted by michaelp
he never asked anything to be compiled, he asked if some more experienced coders could look at his code and give some helpful hints or constructive criticism

edit: did he ask it to be compiled before he edited it?
I messed up on the first post and posted only the attachment, by the time I corrected there half dozen posts already (quick fingers around here!)


Quote:
Originally Posted by _dysfunctional
Just a few pet peeves. You use a lot of global variables rather than passing variables as an argument, and you use a lot of underscores in your variable names.
I guess the underscore thing is more a question personal preference, well, I actualy never though about it, just did.

About the globals, well, nowadays I´m making my life programming on cobol so I still have to learn how to get the best out of functions and arguments. The way I made looks me more readable and easier to track. Why is it a bad habit?

No arguing here, just looking for a better understanding.

btw, the colors variables were all on redraw() function, i moved them out so I could use on others functions.

Thanks for your anwser.
petervaz is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-09-2007, 10:43 AM   #16

Developer
 
yaustar's Avatar
 
Join Date: Jun 2006
Location: UK
Posts: 2,317
Trader Feedback: 0
Default

I just shout off a list as I see them:
  • Macro function instead of inlined function. By doing that you lose type safety and the resulting compiled code may be slower. Also harder to debug.
  • Macro constants where enums should be used.
  • Non constant globals.
  • Inconsistent naming convention for functions and variable names.
  • Use of magic numbers instead of constants.

Globals are bad because any function can access them so it breaks encapsulation and makes it harder to debug as you may not remember which functions change the value of the same global.
yaustar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-09-2007, 12:11 PM   #17
 
Join Date: Apr 2007
Posts: 21
Trader Feedback: 0
Default

Quote:
Originally Posted by yaustar
I just shout off a list as I see them:
  • Macro function instead of inlined function. By doing that you lose type safety and the resulting compiled code may be slower. Also harder to debug.
  • Macro constants where enums should be used.
  • Non constant globals.
  • Inconsistent naming convention for functions and variable names.
  • Use of magic numbers instead of constants.

Globals are bad because any function can access them so it breaks encapsulation and makes it harder to debug as you may not remember which functions change the value of the same global.
Thanks for your feedback. Solid advice in there.
Hmmm... Now I should look up for some terms
petervaz is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-09-2007, 12:54 PM   #18
 
Join Date: Jul 2007
Posts: 296
Trader Feedback: 0
Default

Well, what yaustar is saying...

You do:
Code:
#define addOne(x) x+1
instead of,
Code:
inline int addOne(int x)
{
    return x+1;
}
You do:
Code:
#define PLAYER_ONE 1
#define PLAYER_TWO 2
#define PLAYER_THREE 3
#define PLAYER_FOUR 4
instead of,
Code:
enum PlayerList
{
     PLAYER_ONE = 1,
     PLAYER_TWO = 2,
     PLAYER_THREE = 3,
     PLAYER_FOUR = 4
};
etc, etc.


The rest are simple, so I won't right them up. :P
_dysfunctional is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
experience , fixed

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 07:33 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us