Computer Science Canada

Castle Defender -Boxy the Boxinator

Author:  nick4563 [ Tue Jan 18, 2011 8:11 pm ]
Post subject:  Castle Defender -Boxy the Boxinator

Attached below is my first game in Turing, let me know how it is... Razz

Author:  TerranceN [ Tue Jan 18, 2011 8:27 pm ]
Post subject:  Re: Castle Defender -Boxy the Boxinator

Pretty good for a first game in Turing, you seem to have all the fundamentals down. Unfortunately, there is not much challenge to the game, as all the enemies come from the very bottom, and holding down 1 makes a javelin last forever. Also, from looking at your code, you would benefit a lot from using <a href="http://compsci.ca/v3/viewtopic.php?t=14333">arrays</a>, <a href="http://compsci.ca/v3/viewtopic.php?t=9636">records</a>, and <a href="http://compsci.ca/v3/viewtopic.php?t=14665">procedures</a> that use a parameter to handle things on any enemy you pass to it.

Also, it's spelled <a href="http://knowyourmeme.com/memes/boxxy">Boxxy</a>

Author:  Tony [ Tue Jan 18, 2011 8:31 pm ]
Post subject:  RE:Castle Defender -Boxy the Boxinator

Can't actually run it, but I'll take a look at the code:

code:

var enemy_gone_3 : boolean
enemy_gone_3 := false

things like that scream arrays! Check them out, it will allow you to easily code games with many items/enemies/etc. Also inlining value initializations (var enemy:boolean := false) will make the entire thing look less like a wall of text.

code:

View.Set ("offscreenonly") % makes the flashing graphics static

That's not what offscreenonly does.

code:

drawline * many

If you have a static background, you could just load an image with Pic.FileNew

Or move that chunk of code into a procedure, so that you can have a more understandable loop.

code:

loop
  ...
  Input.KeyDown (chars)
  ...
  Input.KeyDown (chars)

Multiple KeyDown in the same loop are redundant.

Your mixture of tabs and spaces disturbs me and makes reading of your code weird.

code:

   enemy :=true
   
   %Enemy1
    if enemy = true
        then enemy_x1 -= 9
        enemy_x2 -= 9
        drawfillbox (enemy_x1, enemy_y1, enemy_x2, enemy_y2, brightred)
        delay (10)
    else
...

Do you see how the "else" part will _never_ happen? Also, it's a bad idea to have delays anywhere before View.Update. See my comment above on "offscreenonly"

code:

    if Castle_HP < 0
        then
        colourback(red)
        Draw.FillBox(0,0,639,399,black)
        locate(20,30)
        put "GAME OVER"
    end if

I'm pretty sure that the game is still going on in the background, it's just being drawn over.

Author:  nick4563 [ Tue Jan 18, 2011 8:42 pm ]
Post subject:  RE:Castle Defender -Boxy the Boxinator

Thank you for the advice i will make sure to use this for my next game... what does "off-screen-only" do? I took out the else that was a mistake from an earlier version, I took it out of enemy 2 and 3 but forgot 1 I guess... and yes the game still is going on in the back ground but nobody knows that unless they look at the code...

Author:  nick4563 [ Tue Jan 18, 2011 8:49 pm ]
Post subject:  RE:Castle Defender -Boxy the Boxinator

Also how would I make multiple javelins that can be thrown while the other one is on the screen and that cant be held (last forever)??

Author:  Tony [ Tue Jan 18, 2011 8:52 pm ]
Post subject:  RE:Castle Defender -Boxy the Boxinator

offscreenonly does http://en.wikipedia.org/wiki/Multiple_buffering#Double_buffering_in_computer_graphics

edit: the answer is probably "array"s.

Author:  nick4563 [ Tue Jan 18, 2011 9:00 pm ]
Post subject:  RE:Castle Defender -Boxy the Boxinator

Thank you, Tony! I have a feeling I am going to be saying that a lot to you :p

Author:  Tony [ Tue Jan 18, 2011 9:07 pm ]
Post subject:  RE:Castle Defender -Boxy the Boxinator

Hah. If you write some great code and help around here, that'd be cool Wink

Author:  nick4563 [ Wed Jan 19, 2011 4:48 pm ]
Post subject:  RE:Castle Defender -Boxy the Boxinator

Ill help when i can but I'm pretty new and am self taught... I can do easy stuff no prob though.

Author:  nick4563 [ Sun Sep 11, 2011 7:12 pm ]
Post subject:  RE:Castle Defender -Boxy the Boxinator

Im revisiting my old game after quite some time and trying to improve it... I am redoing the scenery and the way the player looks and moves. I am not sure how to have the player shoot more than one bulet at a time... im guessing it has to do with arrays but im rusty and cannot figure it out even after a fair amount of research.

Author:  Aange10 [ Mon Sep 12, 2011 8:13 pm ]
Post subject:  RE:Castle Defender -Boxy the Boxinator

Don't worry, nick. They help you plenty. Good luck on your game! And also, Array are confusing me too!(: ... It's not really the array, just the usage of it. An array is just a bunch of variables in one line/one name.

Turing:

var my_array : array 1 .. 10 of int

So all that is make a variable (var), names it (my_array) and defines it (:) as an array (array) from 1 through 10 (1 .. 10) of integeres (of int)

Reading the turing walkthroughs will help you a ton, and there are some great people here who will help you... Sadly this is as much as I can do for you as I'm not sure how to put arrays into practice. (Like using a for loop with multiple arrays).

Anyways, good luck! And this is the Turing Walkthrough...

Author:  nick4563 [ Tue Sep 13, 2011 4:09 pm ]
Post subject:  RE:Castle Defender -Boxy the Boxinator

Thank you I think I have narrowed it don to flexible arrays using a record but im still lost after that... And I have been through the Turing Walkthrough before... Because I know that is what people are going to say. If somebody could give me an example relevant to my needs that would be very helpful. I am not asking you to write my buleet programming i just need a basis to understand how it works


: