Latest UploadsPlatdude SpottingJayenkaiNom nom nomJayenkaiRainbow TroutPakzKing SalmonPakzSnookerJayenkaiYou've ... o have youJayenkai
 Code Snippets > Variables ( Created 11 May 2016 | Last Edited 11 May 2016)

 Little Spinning Grid by Jayenkai | Rating 75%Handy for Tetris! For general use I'm not 100% sure these will come in handy to anyone, but I just had to figure the bloomin' things out for the umpteenth time, and thought it might be a good idea to jot them down for a change! Assuming your tiles are in an array of 4x4 blocks, where n=(y*4)+x, these are the grid placement values for the two main rotations. 0 (y*4)+x 0,0 1,0 2,0 3,0 0 1 2 3 0,1 1,1 2,1 3,1 4 5 6 7 0,2 1,2 2,2 3,2 8 9 10 11 0,3 1,3 2,3 3,3 12 13 14 15 -1 (x*4)+(3-y) 3,0 3,1 3,2 3,3 3 7 11 15 2,0 2,1 2,1 2,1 2 6 10 14 1,0 1,1 1,2 1,3 1 5 9 13 0,0 0,1 0,2 0,3 0 4 8 12 1 ((3-x)*4)+y 0,3 0,2 0,1 0,0 12 8 4 0 1,3 1,2 1,1 1,0 13 9 5 1 2,3 2,2 2,1 2,0 14 10 6 2 3,3 3,2 3,1 3,0 15 11 7 3 --> Example usage (Blitz2D/3D/Plus) Graphics 800,600,32,2 Global grid[16] Global gridtemp[16] txt\$="ABCDEFGHIJKLMNOP" n=0 For y=0 To 3 For x=0 To 3 grid[n]=Asc(Mid\$(txt\$,n+1,1)) n=n+1 Next Next font=LoadFont("Arial",64,1) SetFont font Repeat Cls If KeyHit(203) Then Spin(-1) If KeyHit(205) Then Spin(1) For x=0 To 3 For y=0 To 3 Text((x*64)+32,(y*64)+32,Chr\$(grid[(y*4)+x]),1,1) Next Next Flip Until KeyDown(1) Function Spin(direction) For x=0 To 3 For y=0 To 3 i=(y*4)+x u=(x*4)+(3-y) If direction=1 Then u=((3-x)*4)+y gridtemp[i]=grid[u] Next Next For x=0 To 3 For y=0 To 3 i=(y*4)+x grid[i]=gridtemp[i] Next Next End Function -->

Posted : Wednesday, 11 May 2016, 13:45
Pakz

Vote : 4
I do not understand what happens in those relevant lines but for what it does it is useful.

-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 570|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
 Latest PostsLaptop Aaargh... Jayenkai Thu 13:40 London Car/Stab Incident Jayenkai Thu 13:36 Watch Switch - Fitbit Blaze Jayenkai Thu 07:04 GamerBlock rockford Thu 06:50 Happy Birthday, Spinal spinal Thu 03:26 Happy Birthday Evil Roy Ferguson rockford Wed 16:21 Spinal's Return to Android Jayenkai Tue 13:41 AGameAWeek : 2017 - Part One Jayenkai Tue 08:10 Poll : Cooking Jayenkai Mon 05:11 Happy Birthday, TheRevillsGames Dabz Sun 23:32 More

 Latest Items Showcase : Infinitronrychan Tue 03:02 Blog : My Arduino experience.steve_ancell Mon 20:27 Dev-Diary : PS2 to N64 Adapterspinal Sun 10:49 Link : Vector Tutorials/Help page.Pakz Thu 23:00 Blog : mini projectspinal Sun 10:13 Showcase : Blockman ReturnsJayenkai Fri 03:04 Snippet : Wall Tracing on Random Maps (rpg)rskgames Wed 22:48 Snippet : Path FollowingPakz Mon 16:25 Snippet : Flowers (Jan 2017)Kuron Thu 01:13 Showcase : Clusters of Hextherevillsgames Mon 15:01 Article : Maths 101 - Episode 1: Basic Trigonometryshroom_monk Sun 14:07 Article : Maths 101 - Episode 5: Line Intersectionshroom_monk Sun 14:02 Dev-Diary : Normals and Dot productsPakz Sat 20:37 Pets : Molly On The CouchJayenkai Thu 04:32 Snippet : Additive Particle FlamesPakz Fri 18:12More

Who's Online
Evil Roy Ferguson
Thu, at 17:36
Jayenkai
Thu, at 16:45
rockford
Thu, at 16:00
spinal
Thu, at 15:12
shroom_monk
Thu, at 14:35
steve_ancell
Thu, at 14:00
HoboBen
Thu, at 13:53
Andy_A
Thu, at 11:38
Pakz
Thu, at 10:03
rskgames
Thu, at 09:43