http://calcg.org/newlogo2.png Not Logged in.
Login | Register

General Discussion Board \ Game and Program Discussion \ Useful Things to Know When Programming

Click here to log in (you must be logged in to post comments).

AuthorComment
IdealIdeas
Marine
Posted: 1 Apr 2009
16:28 GMT
Total Posts: 35
I have been programming games (Rarely ever Finishing them due to constant improvement) for awhile now and I thought I would share some Of my methods that could be useful for using minimal space and have Some tips that someone may not of known.

1. Simple yet better Menu. This Is good for menus that use more than 7 lines and can be made to look nice, or to cut down on using multiple labels along with multiple Menu commands. Below Is the Command Setup:
:Lbl 1 :ClrDraw
:Delvar A :6->B
:Text(0,0,"Menu Title Possibly")
:Text(6,10,"Link 1")
:Text(12,10,"Link 2")
:Text(18,10,"Link 3")
:Text(6,0,"->") (Dash and Greater than symbol, Not a Store Symbol!)
:Repeat A=105 Or A=21
:Delvar A:Getkey->A
:If A=25 or A=34:Then
:Text(B,0,"PLACE 9 SPACES")
:If A=25:B-1->B :If A=34:B+1->B
:If B=0:18->B (THIS IS ONLY SET TO 18 BECAUSE THATS LINK 3 IN THIS EXAMPLE!)
:If B=24:6->B :Text(B,0,"->"):End:End
:If B=6:Goto 2
:If B=12:Goto 3

If You Have Space You Can Even Add Extras Like The Current Time and Ect... Anything that needs to be updated constantly like time would just need to be placed in the Repeat Command. I find making these take use little space and are less Label intensive which is a plus when you may need to use alot of labels for a program.

2. TIP: Avoid Storing Variables to X and Y As using the ClrDraw Command Erases The Variables.

3. Detection System: Used for checking if Pixels are on or off, Which are good for games like Snake, Maze games and more. Now I Prefer Setting My Border Limits To These:
Xmin = 0
Xmax = 94
Ymin = 0
Ymax = 62
Here Is the detection system I though of and It works Pretty fast.
Im Going Use a snake game as an Example of how it detects things to make it better to see how it works
:Lbl 1
:Delvar A :Repeat Z=100 :Delvar A :Getkey->A
:If A=24:1->B :If A=25:2->B :If A=26:3->B :If A=34:4->B
:D->I :E->I
Detection System Start!
:If B=1: D-1->D :If B=2: E+1->E :If B=3: D+1->D :If B=4: E-1->E
:If D>94:1-C :If D<0: 1->C :If E>62 :1->C :If E<0:1->C
:If D<95 and D>-1 and E>-1 and E<63:Then:If Pxl-Test(E-62,D)=1:1->C:End
:If C=1:Goto 2
Detection System End!
:Line(D,E,I,J)
:K+1->K (Snake Size Goal)
:End

Now that I started this, Please post some tips, and/or program setups that you may find to work fast, work better, and/or use less memory. This Could End Up being A Very Useful Topic For Many!
Xphoenix
Ultralisk
avatar
Posted: 1 Apr 2009
20:23 GMT
Total Posts: 210
Try to avoid using so many If statements.

Check out piecewise expressions.

---
~Xphoenix





Portal | My Account | Register | Lost Password or Username | TOS | Disclaimer | Help | Site Search | File Archives Copyright © 2002-2019 CalcG.org