basically the game just looks like this


Code:
              8      V      8
              8              8
              8              8
              8              8
              8              8
              8              8
              8              8
              8              8


and so far for my program i have..


Code:
:1->x
:8->Y
:clrhome
:output(1,5,8
:output(2,5,8
:output(3,5,8
:output(4,5,8
:output(5,5,8
:output(6,5,8
:output(7,5,8
:output(8,5,8
:output(1,12,8
:output(2,12,8
:output(3,12,8
:output(4,12,8
:output(5,12,8
:output(6,12,8
:output(7,12,8
:output(8,12,8
:while 5<Y<12
:output(X,Y,"V
:if Y=5 or Y=12
:then
:goto 1
:end
:getkey->K
:if k=24
:then
:output(X,Y," "         [theres a space there]
:Y+1->Y
:end:end:end
:lbl1
:if Y=5
:then
:output(1,4,"*
:output(1,5,"*
:output(1,6,"*
:else
:if Y=12
:then
:output(1,11,"*
:output(1,12,"*
:output(1,13,"*
:end:end


so this script is all i have so far.
sorry if this isn't written to professional programers standard btw, i just started programming this summer and haven't don't a lot with games. so far this lets your car/ship "V" move left and right.. but when you hit the walls you "crash" making an explosion. what i want now are suggestions on where to go from here. i was thinking about making random ships/cars come towards you and you have to dodge them? anyone have anything better?

thanks in advance :)
OH! p.s, muffinmcfluffin this is the game i asked you about, and thanks for the help so far on it :) (sorry if i spelled your name wrong, i just guessed.
You actually got MufinMcFluffin's name almost exactly right! Welcome to Cemetech, it's great to have you here. We will certainly help you learn BASIC, and hopefully we can teach you a few things about using capital letters at the same time. Wink So, regarding your code, do you want some general suggestions on improving that (for example, you have several memory leaks), or would you prefer more general suggestions on how to add features. To point out one memory leak:

Code:
:if Y=5 or Y=12
:then
:goto 1
:end
A memory leak is whenever you Goto out of a Then/End, For/End, Repeat/End, or While/End construction. You could fix this, for example, with:


Code:
:If Y=5 or Y=12
:Goto 1


Also, if you want something to turn .8xp files into source code for you:

http://sc.cemetech.net

Edit: Joshie, if you wrap your ASCII art in [code] tags, the spacing gets preserved. Please edit your post rather than double-posting if it's within 12 or 24 hours from the post directly before it.
Just suggestions on what kind of game content to put in there, ya know?
And for that memory leak fix, I thought you have to have an end for every loop command?
joshie75 wrote:
Just suggestions on what kind of game content to put in there, ya know?
And for that memory leak fix, I thought you have to have an end for every loop command?
Loop commands are While, For, and Repeat. Then is not a loop command. Basically, if you have:

Code:
:If condition
:Statement
you don't need the Then/End. If you have more than one conditional statement, though:

Code:
:If condition
:Then
:Statement 1
:Statement 2
:Statement N
:End
then the Then/End is necessary. If you find yourself having to Goto out of a While/End, Repeat/End, or For/End loop, you should find an alternative method to break out, such as an extra condition on the While or Repeat, or setting the For() loop's variable to a value larger than its terminating value.

If you were to store the horizontal position of the left and right walls, you could make the walls move by using Disp to scroll the screen up. Many popular BASIC arcade-type games take advantage of that particular construction. As far as gameplay components that you could add, I like the idea of "enemy" vehicles or ships coming at you, and perhaps some kind of shooting (the enemies can shoot at you, and/or you can shoot at them).
Well that makes so much sense, thanks Smile
I actually have never used the for() command. i know that it can make something loop until a variable or time is reached or something, right?
joshie75 wrote:
Well that makes so much sense, thanks Smile
I actually have never used the for() command. i know that it can make something loop until a variable or time is reached or something, right?
May I point you to http://cemetech.net/projects/btutor/btutor.php#14FL for a brief description of For() loops, along with the rest of my BASIC tutorial?

Edit: Something nice to do with a For() loop: compress

Code:
:output(1,5,8
:output(2,5,8
:output(3,5,8
:output(4,5,8
:output(5,5,8
:output(6,5,8
:output(7,5,8
:output(8,5,8
to
Code:
For(X,1,8
:Output(X,5,"! {this is in [math][left][4]}
:End
You don't have to switch from 8 to !; that's just my own stylistic edit.
Hahaha, no don't worry about misspelling my name, as long as we know who you're talking about.

I see you've met the founder of the site, KermMartian (we just call him Kerm).

As for the code, you'll want to take steps at a time, getting all your small parts of the code to work together. I suggest going from having it move around, to having it move around with other things moving as well, then you having to dodge things, then maybe a health system, then different objects that will do different amounts of damage, and so on. Ooooh, maybe even different objects will travel at different speeds? That could be pretty cool.

This may sound like a lot to do, but if you're dedicated to this project, we'll be able to help you get from start to finish. I can't guarantee that there won't be a few bumps on the way, but we can be sure you get there.
alright, these all seem like good suggestions Smile

so say i move this from the home screen to the graph screen..
the only thing id have trouble with is the health bar :S

i know about the shade( command.. but i only know how to do it across the whole screen, across half of the screen, how tall to make it, and if it ends in a 0 its white, 1 its black. help? thanks Smile
Thanks Mufinator, welcoming and friendly as always. I understand that you steered Joshie75 here, which I appreciate. Smile As Mufinator says, we can give you suggestions, help, and code review, and hopefully along the way you'll build your experience and skills. Do you have any ideas on mine and Mufinator's ideas (the latter of which are excellent)?

Edit:
joshie75 wrote:

so say i move this from the home screen to the graph screen..
the only thing id have trouble with is the health bar :S

i know about the shade( command.. but i only know how to do it across the whole screen, across half of the screen, how tall to make it, and if it ends in a 0 its white, 1 its black. help? thanks Smile


So, it would be better to use line commands for that. The syntax for Line is Line(X1,Y1,X2,Y2). That draws a black line on the screen from (X1,Y1) to (X2,Y2). There's an optional fifth argument; if you set it to zero, the Line() command erases where that line would be (ie, white) instead of drawing the line (ie, black). You could use four line commands to draw the outside of the health meter, then a For() loop of Line() commands to draw the current level of health. For example:


Code:
:AxesOff:ClrDraw
:0->Xmin:0->Ymax
:1->deltaX:1->deltaY
:"Assume that the health level is 0-100, in variable H"
:Line(1,-1,22,-1
:Line(1,-1,1,-7
:Line(22,-7,22,-1
:Line(22,-7,1,-7
:"Now the box is drawn, and we can draw the bar"
:For(X,-6,-2
:Line(2,X,2+.2H,X
:End
Here the box has a blank inside space of 20x5 pixels, and we draw the border as 22x7.
so ive decided to go from using the graph screen back to using the home screen for this. im trying to make enemies (I) at your piece. i cant make the I come at me correctly :S heres my code..


Code:
:1->x
:8->Y
:clrhome
:output(1,5,8
:output(2,5,8
:output(3,5,8
:output(4,5,8
:output(5,5,8
:output(6,5,8
:output(7,5,8
:output(8,5,8
:output(1,12,8
:output(2,12,8
:output(3,12,8
:output(4,12,8
:output(5,12,8
:output(6,12,8
:output(7,12,8
:output(8,12,8
:while 5<Y<12
:8->B
:randInt(6,11)->A
:Output(B,A,"I
:B-1->B
:Output(B,A," "      [theres a space here]
:output(X,Y,"V
:if Y=5 or Y=12
:then
:goto 1
:end
:getkey->K
:if k=24
:then
:output(X,Y," "         [theres a space there]
:Y+1->Y
:end:end:end
:lbl1
:if Y=5
:then
:output(1,4,"*
:output(1,5,"*
:output(1,6,"*
:else
:if Y=12
:then
:output(1,11,"*
:output(1,12,"*
:output(1,13,"*
:end:end
Well, the main problem is probably your While statement. You unfortunately can't do that.


Code:
while 5<Y<12
must be
Code:
While 5<Y and Y<12
.

To clean your code up a tad:


Code:
:1->x
:8->Y
:clrhome
:For(X,1,8
:output(X,5,8
:output(X,12,8
:End
:While 5<Y and Y<12
:8->B
:randInt(6,11->A
:Output(B,A,"I
:B-1->B
:Output(B,A," "      [theres a space here]
:output(X,Y,"V
:if Y=5 or Y=12
:Goto 1
:getkey->K
:if k=24
:then
:output(X,Y," "         [theres a space there]
:Y+1->Y
:end:end:end
:lbl1
:if Y=5
:then
:output(1,4,"*
:output(1,5,"*
:output(1,6,"*
:else
:if Y=12
:then
:output(1,11,"*
:output(1,12,"*
:output(1,13,"*
:end:end
KermMartian wrote:
A memory leak is whenever you Goto out of a Then/End, For/End, Repeat/End, or While/End construction. You could fix this, for example, with:


Code:
:If Y=5 or Y=12
:Goto 1

This might not be the right place to ask this but it came up. For the sake of education as you like to say, I was wondering what damage if any do these leaks cause. I like to use things like this. What is the problem with this? I have never had an error using it this way. I could use another lbl. But why should I? Is there some reason I should not use it this way, and is this cause for a memory leak in this situation?

Code:
:Lbl A
:*Maybe Some output here or something else to save space.
:While 1
:getkey->A
:If A=26:Then
:If D=1:Goto A
:10->F
:B+1->B
:C+1->C
:prgmEXODUS
:If E=1:Goto B
:End
:If A=
:
:End
A memory leak only occurs when you Goto from a If-Then block or a loop. The leak won't be obvious at first, but after many iterations of that loop you will see a slowdown or a memory error.
basicman wrote:
KermMartian wrote:
A memory leak is whenever you Goto out of a Then/End, For/End, Repeat/End, or While/End construction. You could fix this, for example, with:


Code:
:If Y=5 or Y=12
:Goto 1

This might not be the right place to ask this but it came up. For the sake of education as you like to say, I was wondering what damage if any do these leaks cause. I like to use things like this. What is the problem with this? I have never had an error using it this way. I could use another lbl. But why should I? Is there some reason I should not use it this way, and is this cause for a memory leak in this situation?

Code:
:Lbl A
:*Maybe Some output here or something else to save space.
:While 1
:getkey->A
:If A=26:Then
:If D=1:Goto A
:10->F
:B+1->B
:C+1->C
:prgmEXODUS
:If E=1:Goto B
:End
:If A=
:
:End



I am not sure about if you use any of the libraries that have been made to work with the calculators, but with pure BASIC, you shouldn't have anything worse then what Souvik said. Though I think (not positive) if you use a third-party library and depends on what is needed (or even ASM), then you could trigger a ram clear, or if using DCS, I think it can cause a garbage collect, though I do not know those for sure.
Souvik was correct; all that will happen is your program will get slower and slower until an ERR:MEMORY occurs. No crashiness will happen with third-party hybrid libraries unless they're poorly-coded to deal with low memory conditions.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement