Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

help I'm a noob!

Name: Anonymous 2007-08-13 19:57 ID:RmFCahfF

So this is my first time programming with basic, self-taught, and I'm making a Space Invaders-type program. What I would like is for there to be a short intro with a little plotline (which I've already written), and then for the game to start. Unfortunately, the script I have will go through the intro, but then will end once it gets to the game part. There's nothing wrong per se with the script I have, but I think it's missing something to make it work...is there a way to make it reset everything and start with new code (so it forgets all the stuff in the intro after the intro is over, and starts the game)?

Name: Anonymous 2007-08-13 20:09 ID:7XWwvI+S

Well, I'm a little confused by this line:

I think it's missing something to make it work...is there a way to make it reset everything and start with new code

If you wrote it I would think you would know this. You need to describe your code a little or something.

Name: Anonymous 2007-08-13 20:14 ID:sdn4lUGu

take this shit to /g/, they need more threads like this

Name: Anonymous 2007-08-13 20:26 ID:Heaven

>>3
>>2
die

Name: OP 2007-08-13 20:29 ID:RmFCahfF

>>2

I mean, I make it clear the screen, and then I write the code for the game... but it just ends after the intro to the game ends. But, once the screen clears, I have the dimensions and stuff there, and I don't know if there's something else I'm supposed to write to make it recognize that a game should start. I can post the entire code for someone to scan if it's necessary.

Name: Anonymous 2007-08-13 20:32 ID:7XWwvI+S

>>5
Maybe you ought to, if we can't figure this out. What language are you writing this in again? I would expect a normal game to go something like:

main function = {intro(); game-loop(); end()}

The way you're talking about making something recognize that the game should start confuses me.

Name: OP 2007-08-13 20:38 ID:RmFCahfF

>>6
I'm writing in BASIC. Here's the script I wrote:

printr "Hi."
sleep (3000)
printr "Welcome to Bootlegged Space Invaders."
sleep (3000)
printr "Are you ready?"
sleep (3000)
printr "Here we go!"
sleep (3000)
cls
dim i
for i = 0 to 9
    printr 10 - i
    Sleep (1000)
next
print "Blastoff!"
sleep (2000)
cls           
sleep (1000)
dim x
for x = 0 to 25
cls
locate x, 12
print "*<==>"
Sleep (200)
next     
cls
printr "BLAMMO!"
printr " "
sleep (3000)
printr "Captain: WTF!"
printr " "
sleep (3000)
printr "Aliens: OLOL WE HAS STOELD UR INTARNETZ"
printr " "
sleep (3000)
printr "Captain: O SHI--!"                                       
printr " "
sleep (3000)
printr "Aliens: NO TIEMZ 2 SURVIV SO DIE PLZKTHX"  
printr " "
sleep (3000)
printr "Lieutenant: Come on Captain, let's beat the shit outta these guys!"  
printr " "
sleep (3000)
printr "Captain: Right! Prepare battle stations!"  
printr " "
sleep (3000)
printr "Lieutenant: Move zig!"  
printr " "
sleep (2000)
printr "Captain: For great justice!"
sleep (3000)
cls        
sleep (2000)                
print "STAGE 1: THE FINAL COUNTDOWN"
sleep (5000)     
cls          

dim score, lives, turretx, alienx, alieny
dim bulletx, bullety, bulletOnScreen, i
lives = 3   
turretx = 19                    
alienx = 0                            
alieny = 12
bulletOnScreen = false
      
TextMode (TEXT_BUFFERED)
while true              
if ScanKeyDown (VK_DOWN) and turretx > 0 then
turretx = turretx - 1
endif
if ScanKeyDown (VK_RIGHT) and turretx > 37 then
turretx = turretx + 1
endif                
alienx = alienx + 1
if alienx > 37 then
alienx = 0
alieny = rnd () % 22 + 1
endif                      
if bulletOnScreen then
bullety = bullety - 1
if bullety < 1 then
bulletOnScreen = false
endif
else
if ScanKeyDown (VK_SPACE) then
bulletOnScreen = true
bullety = 22
bulletx = turretx + 1
endif
endif
cls
color (255, 255, 255)
locate 0, 0: print "Score=" + score
locate 30, 0: print "Lives=" + lives
color (255, 50, 50)
locate alienx, alieny: print "<-@->"
color (150, 150, 150)
locate turretx, 23: print "||"        
if bulletOnScreen then
color (255, 255, 50)
locate bulletx, bullety: print "*" 
endif                              
if bulletOnScreen and bullety = alieny and bulletx >= alienx and bulletx <= alienx + 4 then
color (255, 255, 100)
for i = 1 to 10
locate alienx, alieny: print "*BIF*"
DrawText ()
Sleep (50)
locate alienx, alieny: print "***"
Sleep (50)
next
bulletOnScreen = false
alienx = 0      
alieny = rnd () % 22 + 1
score = score + 100
sleep (1000)
endif

DrawText ()      
sleep (75)
wend

As you can see, there's the intro to the level "THE FINAL COUNTDOWN", and then I start writing about variables and the actual game code. I have a suspicion that it doesn't agree with the variables not being addressed at the beginning of the code, but I tried putting them there and it didn't make a difference. So...I'm not sure what to do.

Name: Anonymous 2007-08-13 20:50 ID:Heaven

sage for BASIC.

Name: Anonymous 2007-08-13 20:59 ID:RwxhmHVT

dear god

are you for real?

anyway, google for SICP, it should tell you all you need to know

Name: Anonymous 2007-08-13 21:05 ID:sdFyy/le

Holy shit, I forgot how ugly BASIC was. Switch to C++, seriously. And SCREEN 13 ftw if you insist on basic.
As for your problem, it could be that BASIC is gay and your while criteria is evaluated as satisfied when it hits it and just breaks. Perhaps, as suggested in /g/, make a variable called exit or something, initalize it to 1, and have the while be while exit == 1.

Name: Anonymous 2007-08-13 21:07 ID:7XWwvI+S

Indentation, motherfucker, have you heard of it? Functions are nice too. I'm not spotting the problem immediately, but if you rearrange this to have a modicum of structure this should work out better.

And why the hell are you making a text game in BASIC? It's no easier than doing graphics in a decent language.

Name: OP 2007-08-13 21:20 ID:RmFCahfF

>>11

It is indented in the compiler but something went wrong with copypasta.

I'm using basic because it seemed simple enough to start out with. I don't really plan on programming as a career, I just wanted to try writing simple programs and stuff with it. I'd love to write in C++ but it blows my mind. If I get there I'd like to work my way up from something more english-y first.

>>10 and >>9 I'm trying out your suggestions now.

Name: OP 2007-08-13 21:28 ID:RmFCahfF

GREAT SUCCESS!

I have found the source of the problem! BEHOLD!:

dim i
for i = 0 to 9
    printr 10 - i
    Sleep (1000)

*later in the script*

dim score, lives, turretx, alienx, alieny, bulletx, bullety, bulletOnScreen, i

I'm such a dumbass. Thanks for the assistance, you guys. I appreciate it.

Name: Anonymous 2007-08-13 21:50 ID:7XWwvI+S

Good show, sir.

Name: Anonymous 2007-08-14 1:38 ID:KKaqIvnS

>>10
Holy shit, I forgot how ugly BASIC was. Switch to C++, seriously.
Holy shit, I forgot how ugly COBOL was. Switch to PHP, seriously.

Name: Anonymous 2007-08-14 3:45 ID:yIMQ67W4

>>10
const int& const volatile function auto register const char * []*[] function(int& *arg[], <char>float*& something)

Name: Anonymous 2007-08-14 5:21 ID:vpv8U7f4

>>12
Programming languages aside, I'm happy to know that some people take the initiative to start programming rather than the rest who just come to prog and post shit like "how do i maek game? i want to maek game in see plus plus".

Good luck with your Space Invaders.

Name: Anonymous 2007-08-14 9:46 ID:a5Ry2tkq

>>17
>>1

Yes, fuck BASIC and g/l with that game!

srsly tho, you may want to try something like python. it's just as easy, and everyone will think you're cool cept the red herring

Name: Anonymous 2013-01-19 0:06

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Don't change these.
Name: Email:
Entire Thread Thread List