Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Math-O-Spheres

  1. #11

    Math-O-Spheres ZIPped file

    Here's the link at MediaFire -- I couldn't upload the ZIP file using the "Manage Attachments" window...

    https://www.mediafire.com/?l9lp8cersb44iki

  2. #12
    I have just checked your code.
    There is no easy way to say this but your code is a mess. That is why I won't simply just do some changes to your code in order to solve your problem as I would have to change lots of it and you probably wouldn't understand what I did and why.
    So instead I will try to tell you which parts of your code are god and which are not god and should be changed.
    1. It was quite clever of you to use TDrawGrid for Cell picking. I myself probably would have never used that but instead do my own math for that similar as in that example of mine I posted before.
    2. Why do you have 128 Images in your ImageList? And most of all why do you have same images at multiple indexes? Don't tell me that you are trying to use that image list to store the position of different Spheres in the grid.
    I only recomend your ImageList to contain only all posbile spheres available (+1, +2, +3, ...,+9, -1, -2, ...). Then you only need to define somewhere in your program which ImageList index is used for which sphere. Note image list index starts with 0 and not 1.
    3. You should store spheres information in two dimensional array like so:
    Code:
    var SphereMap: Array [0..7, 0..15] of Integer;
    4. Upond clicking on certain cell you could use the information from that same array to find out what to do like so:
    Code:
    case SphereMap[row, column] of
      1: Sum := Sum + 1; // +1 Sphere
      2: Sum := Sum + 2; // +2 Sphere
      ...
      10: Sum := Sum - 1; // -1 Sphere
      11: Sum := Sum - 2; // -2 Sphere
      ...
    end;
    5. In your code you say that you set the starting time to 15 seconds but you have your timer interval set to half a second. So the player actually doesent have 15 seconds as stated.
    6. I advise you set the ProgressBar max value to the starting time. This way progressBar will start being full and not only partially full as it does now.
    7. Infact using TProgressBar might not be the best idea. Why? On windows Vista and newer the ProgressBar will show that default Windows ProgressBar moving animation which might not be desirable. You can use TGauge instead. It's usage is quite similar to ProgressBar but its look is not afected by the operating system you are running your program on.

    So these are my coments and suggestions on your project so far. I hope they will be helpfull.
    And you can always ask for further advice if you need it.

  3. #13
    You're right about things being a mess, I was planning to clean them up after I had everything working.

    1.) Thanks.

    2.) That was a temporary measure; I actually wanted to iterate through a length: nine (0 through 8 ) list randomly 128 times, at which point the grid would be filled. I haven't done that mainly because I'm currently working on the "chain" functionality of the game.

    3.) I have the code for that, but haven't finished implementing it.

    4.) Thanks.

    5.) I was planning to make the game time around one minute, but have it set to fifteen seconds from when I was testing to make sure the Game Over events were working. Waiting all that time just for the game to end seemed like a waste.

    6.) I've already done that; the current length is only temporary. Once I've set the final length, the bar will start full.

    7.) Didn't know that. Thanks.

    You've been more than helpful. I really appreciate you taking time out of your day to do this.
    Last edited by sewing0109; 13-05-2014 at 08:19 PM. Reason: Random smiley where the 8 and the ) met

  4. #14
    No problem. If you will have any other questions don't be shy.

  5. #15
    I'm still not sure how to iterate over the imagelist.

    The code I have is...

    index := ARow * grdPlayField.ColCount + ACol;
    grdPlayField.Canvas.Brush.Color := clMaroon;
    grdPlayField.Canvas.FillRect(Rect);
    imlSpheres.Draw(grdPlayField.Canvas,Rect.Left,Rect .Top,index, True);
    if (gdFocused in State) then
    begin
    grdPlayField.Canvas.DrawFocusRect(Rect);
    end;


    ...It works for simply displaying the nine items on the grid in the appropriate cells, but I can't figure out how to tell Delphi to keep assigning the elements until the grid is full.

  6. #16
    You're only showing what you do with 1 element. Is there a for or while structure we can take a look at? Iterating 2D table is really easy
    Code:
    var i, j: integer;
    ...
    for j:=0 to RowCount-1 do
      for i:=0 to ColCount-1 do
      begin
        // Do something with element[i, j] ...
    
      end;

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •