I'm trying to be a bit more structured whilst I'm learning Pascal...I know there are style guides - but don't know if there are programming techniques. I get easy muddled up and have looked at some previous code I have done at it all looks rather messy. The plan I have come up with (don't think it is original) is something along the lines of this;
program MyBigGame;
procedure SetUps();
begin
{ Code here intializes variables etc }
end;
procedure GamerInput();
begin
{ Code here takes instructions from keyboard and mouse }
end;
procedure RefreshScreen();
begin
{ code here does all the foreground and background stuff }
end;
{ Main }
BEGIN
SetUps;
repeat
GamerInput;
Logic;
RefreshScreen;
until GameOver=True;
END.
Now on top of this have decided that in MyBigGame to label any associated 'sub-procedures' as follows;
procedure R_Score();
begin
{ Code to draw the score to the screen }
end;
procedure L_Physics();
begin
{ Code that does the collision detection etc. }
end;
So you see the prefix R_ is associated with the "main procedure" RefreshScreen; and L_ is associated with the "main procedure" Logic; ...and so on...
That way I can clearly see what fits where....
Now my next question is; is this good practice? How do other people do it? I'm an amateur, and don't work anywhere near the industry...but really want to do this one day as a professional career in some form. My "IDE of choice" at the moment is MIDlet Pascal...decided to focus around that familiarity whilst learning before I move up to a more complex IDE...
(oops there should be TABS as well in the "Main" so sorry if it all lefthand sided)
Bookmarks