Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
simple text game
Author Message
do_pete

Posted: Wed Nov 02, 2005 2:52 pm   Post subject: simple text game

i was board in my computers class so i made this.
You are the green asterick and you try to run away from the other ones.

 code: var PlayerX, PlayerY : int := 1 var AIX, AIY : array 1 .. 50 of int var AITurn, AIAppear, AIArrayNum, ANum : int := 1 var key : array char of boolean var YouLoose, Exit : boolean := false var answer : char procedure ControlPlayer     Input.KeyDown (key)     if key (KEY_RIGHT_ARROW) then         PlayerX += 1     elsif key (KEY_LEFT_ARROW) then         PlayerX -= 1     end if     if key (KEY_UP_ARROW) then         PlayerY -= 1     elsif key (KEY_DOWN_ARROW) then         PlayerY += 1     end if     if PlayerX > maxcol then         PlayerX := maxcol     elsif PlayerX < 1 then         PlayerX := 1     end if     if PlayerY > maxrow then         PlayerY := maxrow     elsif PlayerY < 1 then         PlayerY := 1     end if end ControlPlayer procedure DrawPlayer (x, y : int)     Text.Locate (y, x)     put "*" .. end DrawPlayer procedure AI     if AITurn >= 1 then         if PlayerX > AIX (ANum) then             AIX (ANum) += 1         elsif PlayerX < AIX (ANum) then             AIX (ANum) -= 1         end if         if PlayerY > AIY (ANum) then             AIY (ANum) += 1         elsif PlayerY < AIY (ANum) then             AIY (ANum) -= 1         end if     end if end AI procedure Beginning     Text.Locate (maxrow div 2 - 1, maxcol div 2 - 7)     put "Peter Do's Game"     Text.Locate (maxrow div 2, maxcol div 2 - 11)     put "Press any key to begin"     View.Update     Input.Pause     cls     View.Update end Beginning View.Set ("offscreenonly,graphics:400;400,title:Peter Do's Game,nobuttonbar,position:middle;middle,nocursor") Text.Colour (brightred) Beginning loop     for i : 1 .. 50         randint (AIX (i), 1, maxcol)         randint (AIY (i), 1, maxrow)     end for     loop         ControlPlayer         Text.Colour (green)         DrawPlayer (PlayerX, PlayerY)         AITurn := (AITurn + 1) mod 2         AIAppear := (AIAppear + 1) mod 25         if AIAppear >= 24 then             AIArrayNum += 1         end if         Text.Colour (brightred)         for i : 1 .. AIArrayNum             DrawPlayer (AIX (i), AIY (i))             ANum := i             AI             if AIX (i) = PlayerX and AIY (i) = PlayerY then                 YouLoose := true                 exit             end if         end for         View.Update         cls         delay (100)         if YouLoose = true then             exit         end if     end loop     cls     Text.Locate (maxrow div 2 - 1, maxcol div 2 - 5)     put "You Loose!"     Text.Locate (maxrow div 2, maxcol div 2 - 7)     put "Your Score is ", AIArrayNum     Text.Locate (maxrow div 2 + 1, maxcol div 2 - 17)     put "Would you like to play again(Y/N)?"     View.Update     loop         answer := getchar         if answer = "N" or answer = "n" then             Exit := true             exit         elsif answer = "Y" or answer = "y" then             exit         end if     end loop     exit when Exit = true     PlayerX := 1     PlayerY := 1     AITurn := 1     AIAppear := 1     AIArrayNum := 1     ANum := 1     YouLoose := false     Exit := false     cls end loop

Posted: Wed Nov 02, 2005 3:23 pm   Post subject: (No subject)

wow, very neat! you can make some of the stars go into eachother if you time it right, but, other than that, very neat tag game! GJ!
beard0

Posted: Wed Nov 02, 2005 4:05 pm   Post subject: (No subject)

Wow, more than descent - small code, yet playable. Score: 25 on second try
Tony

Posted: Wed Nov 02, 2005 4:25 pm   Post subject: (No subject)

you might be interested in checking out zylum's and Cervantes' games
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 4 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: