1 Replies - 68 Views - Last Post: 11 January 2019 - 09:04 AM Rate Topic: -----

#1 kiddcamel   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 11-January 19

Creating character boundaries in Turing

Posted 11 January 2019 - 08:55 AM

I am creating a game for my summative using Turing. I'm not too familiar with how to use Turing so this is a very hard task. Anyways, I am creating a game with a movable character. I am trying to make obstacles in which if you touch them you die. I can't figure out how to it though. I have added a rectangle and don't know what to do from here. Here is the code:
%Global variables
import GUI 
var characterColour: int
var font4 : int
var font3 : int
var chars : array char of boolean 
var x : int := 5 
var y : real := 5 
var startButton : int := GUI.CreateButton (maxx div 2, maxy div 2, 0, "start", GUI.Quit)
%Main Code

%MAIN MENU
font4 := Font.New ("Palatino:24:Bold,Italic")
font3 := Font.New ("Palatino:12:Bold,Italic")
%Title
Font.Draw ("DEATH RUN", 250, maxx div 2, font4, red)
Font.Draw ("how long will you survive?", 240, 300, font3, red)
loop
    exit when GUI.ProcessEvent
end loop
cls




%LEVEL 1
%Ball Movement




proc jump 
    for angle : 0 .. 180 by 5 
        Input.KeyDown (chars) 
        if chars (KEY_RIGHT_ARROW) then 
            x += 2 
        end if 
        if chars (KEY_LEFT_ARROW) then 
            x -= 2 
        end if 
        y := 5 
        y += 140 * sind (angle) 
        drawfilloval (x, round (y), 5, 5, red) 
        View.Update 
        delay (25) 
        drawfilloval (x, round (y), 5, 5, colorbg) 
    end for 

end jump 


loop 
    Input.KeyDown (chars) 
    if chars (KEY_UP_ARROW) then 
        jump 
    end if 
    if chars (KEY_RIGHT_ARROW) then 
        x += 2 
    end if 
    if chars (KEY_LEFT_ARROW) then 
        x -= 2 
    end if 
      if x = 80 then
    put "You lost."
    end if
    
    
    drawfilloval (x, round (y), 5, 5, red) 
    View.Update 
    delay (10) 
    drawfilloval (x, round (y), 5, 5, colorbg) 
    
  
    
    Draw.FillBox (80, 40, 100, 0, 2)

end loop 
:code:

I tried to use if x = 80 then
put "You lost."
end if
to gie the message of you lost if you touch this area but can't get it to work. What should I do? Some help would be greatly appreciated. :)/>

This post has been edited by modi123_1: 11 January 2019 - 09:03 AM
Reason for edit:: In the future, please use the [code] tag button in the editor.


Is This A Good Question/Topic? 0
  • +

Replies To: Creating character boundaries in Turing

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14691
  • View blog
  • Posts: 58,718
  • Joined: 12-June 08

Re: Creating character boundaries in Turing

Posted 11 January 2019 - 09:04 AM

Curious question - are you using Turing because it is part of your assignment, or why not go for a different, more familiar, language?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1