Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Uncle Worm, Leveling Up
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Mr. T




PostPosted: Sat Mar 19, 2005 10:51 pm   Post subject: Uncle Worm, Leveling Up

In my game...after reaching a score of 50, i want to "level up"
By leveling up, i mean 1. eliminating the creation of food until the next
level is reached
2. creating an exit point
3. seeing if that exit point has been reached
(whatdotcolour)
4. decreasing the screen dimensions upon reaching
the exit points
and then after another 50 points, repeat this process
--------------------------------------------
how would i go about doing this?
should i save things as procedures?
heres my code...



code:

%variable declaration
View.Set ("graphics:400;300,title:Uncle Worm           Score: 0")
var food1 : int
var food2 : int
var foodSize : int
var box1 : int := 0
var box2 : int := maxy
var box3 : int := maxx
var box4 : int := 0
var col : int := 31
var countdown : int := 6
var ballx1 : int := 200
var bally1 : int := 150
var ballsize : int := 5
var move, move2, move3, move4 := false
var key : array char of boolean
var ring : int := 0
var answer : string
move3 := true %starting direction of snake
var score : int := 0
var newMaxX : int := 400 %innitial screen dimensions (x co-ords)
var newMaxY : int := 300 %innitial screen dimensions (y co-ords)
var levelUp : int := 10 %decrease in screen dimensions upon completion of level
var scoreLevel : int := 10

%gives time for user to get ready
loop
    locate (9, 18)
    put "Starting in...", countdown - 1
    delay (300)
    countdown := countdown - 1
    cls
    exit when countdown = 0
end loop


%creates food in random locations
procedure food
    randint (food1, 1, 395) %random food location (but not in the walls)
    randint (food2, 1, 295) %random food location (but not in the walls)
    randint (foodSize, 2, 10) %random food size
    drawfilloval (food1, food2, foodSize, foodSize, 2)
end food

%point of contact upon death
procedure ringEnd
    loop
        drawoval (ballx1, bally1, ballsize + ring, ballsize + ring, ring)
        ring += 2
        delay (10)
        exit when ring = 100

    end loop
end ringEnd

%draws food
food

%snake movement
loop
    drawbox (box1, box2, box3, box4, 7)
    drawfilloval (ballx1, bally1, ballsize, ballsize, col)
    if move then
        bally1 += 1
    elsif move2 then
        bally1 -= 1
    elsif move3 then
        ballx1 += 1
    elsif move4 then
        ballx1 -= 1
    end if
    Input.KeyDown (key)
    if key (KEY_UP_ARROW) and move2 = false then %Two Conditions: 1. up arrow is pressed 2. move2 = false
        move2 := false
        move3 := false
        move4 := false
        move := true
    elsif key (KEY_DOWN_ARROW) and move = false then  %Two Conditions: 1. down arrow is pressed 2. move = false
        move := false
        move3 := false
        move4 := false
        move2 := true
    elsif key (KEY_RIGHT_ARROW) and move4 = false then %Two Conditions: 1. right arrow is pressed 2. move4 = false
        move := false
        move2 := false
        move4 := false
        move3 := true
    elsif key (KEY_LEFT_ARROW) and move3 = false then   %Two Conditions: 1. left arrow is pressed 2. move3 = false
        move := false
        move2 := false
        move3 := false
        move4 := true
    end if
    drawfilloval (ballx1, bally1, ballsize, ballsize, 12)     %deletes the tail
    delay (10)

    %wall collision detection
    if ballx1 = 4 or ballx1 = maxx - 4 or bally1 = 4 or bally1 = maxy - 4 then
        View.Set ("graphics:" + intstr (newMaxX) + ";" + intstr (newMaxY) + ",title:Uncle Worm           Score: " + intstr (score) + "             You Lose!")
        ringEnd
        exit
    end if

    %food collision detection
    if whatdotcolour (food1 + foodSize, food2 + foodSize) = 12 or whatdotcolour (food1 - foodSize, food2 - foodSize) = 12
            then
        score += 10 %when food collision detected points are added to score
        View.Set ("graphics:" + intstr (newMaxX) + ";" + intstr (newMaxY) + ",title:Uncle Worm           Score: " + intstr (score))
        drawfilloval (food1, food2, foodSize, foodSize, white)      %so that no chunk of food is left behind
        food %when collision detected food is redrawn
    end if


    %NEXT LEVEL
    if score = scoreLevel
            then
        drawfillbox ((maxx div 2) - 10, maxy, (maxx div 2) + 10, maxy - 5, 4)
        scoreLevel += 10
        exit when whatdotcolour (ballx1+ballsize,bally1+ballsize)=4
    end if


end loop




       /*
 View.Set ("graphics:" + intstr (newMaxX-levelUp) + ";" + intstr (newMaxY-levelUp) + ",title:Uncle Worm           Score: " + intstr (score))
 */

View.Update







-------------------------------------
p.s. i realize my snake doesnt grow...im saving the flexible array part for the end, because ive yet to learned it

and

could someone help me with my whatdotcolour for the exit point Smile
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sun Mar 20, 2005 8:59 am   Post subject: Re: Uncle Worm, Leveling Up

Pwned wrote:
In my game...after reaching a score of 50, i want to "level up"
By leveling up, i mean 1. eliminating the creation of food until the next
level is reached
2. creating an exit point
3. seeing if that exit point has been reached
(whatdotcolour)
4. decreasing the screen dimensions upon reaching
the exit points
and then after another 50 points, repeat this process


check the whatdotcolour thread, then come here.
1.)you could make a flag variable (a boolean variable) and set it to true every time you enter a new level. When you've got enough points, set it to false. Only draw food if the flag is true.
2.) You've done that, right?
3.) other thread.,
4.) View.Set. You can do that.

However, instead of having a exit when you collide with the exit, you should have aprocedure that will create the next level.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: