Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Arrays. Again.
Author Message
Neja

Posted: Tue Jun 08, 2004 1:12 pm   Post subject: Arrays. Again.

Allright, Tetris was annoying me and I'm running out of time, so I've sort of simplified it. Instead of hapes being dropped, I have two boxes of random colours (each can be different) dropping. The object is to make three in a row (horixontal, vertical, even in "L" shapes). The problem I'm having is this; I havae the boxes dropping (using arrays), and I can speed them up if you press the down button as well as move to the left, but for some reason, the same logic does not apply to moving them to the right.
[/code]
var grid : array 1 .. 20, 1 .. 20 of int
for i : 1 .. 20
for j : 1 .. 20
grid (i, j) := 0
end for
end for

loop
for i : 1 .. 20 % For down.
for j : 1 .. 20
if grid (i, j) not= 0 and j > 1 then
if grid (i, j - 1) = 0 then
grid (i, j - 1) := grid (i, j)
grid (i, j) := 0
end if
end if
end for
end for
/*for i : 1 .. 20 % For down. % For moving left.
for j : 1 .. 20
if grid (i, j) not= 0 and i > 1 then
if grid (i-1, j ) = 0 then
grid (i-1, j := grid (i, j)
grid (i, j) := 0
end if
end if
end for
end for

for i : 1 .. 20 % For down. % For moving right, but it doesn't work.
for j : 1 .. 20
if grid (i, j) not= 0 and i > 1 then
if grid (i+1, j ) = 0 then
grid (i+1, j := grid (i, j)
grid (i, j) := 0
end if
end if
end for
end for
*/
for i : 1 .. 20
for j : 1 .. 20
Draw.FillBox (i * width, j * width, i * width + width, j * width + width, grid (i, j))
end for
end for
for i : 1 .. 20
for j : 1 .. 20
Draw.Box (i * width, j * width, i * width + width, j * width + width, gray)
end for
end for
View.Update
delay (200)
end loop
 code: It's a little out of order, beccuase I cut and pasted, but that's basically it.

SuperGenius

Posted: Tue Jun 08, 2004 4:03 pm   Post subject: (No subject)

you code has a lot of errors. it is difficult for me to understand what you are doing; also if you document your program it is easier to help.
Neja

Posted: Tue Jun 08, 2004 10:30 pm   Post subject: (No subject)

Thank you anyways. I got it. The problem was that for the right, I should be using a for decreasing loop.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 3 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: