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

Username:   Password: 
 RegisterRegister   
 Mario Help Needed!!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Deep613




PostPosted: Thu Jul 03, 2014 10:30 am   Post subject: Mario Help Needed!!

This is my Mario game. There are so many bugs in the game. Coins do not disappear, mario is unable to find contact, as my screen is moving, I am unable to use any other moving object . Any help will be appreciated.

Thanks!


Turing version: 4.1



Mario Bros!.zip
 Description:
This is my game with source code.

Download
 Filename:  Mario Bros!.zip
 Filesize:  2.97 MB
 Downloaded:  494 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Thu Jul 03, 2014 11:28 am   Post subject: RE:Mario Help Needed!!

Copy & paste the code onto here and I'll have a look. You might want to be more descriptive of your issues though- it sounds like these aren't bugs so much as you just haven't written the code yet.
Deep613




PostPosted: Thu Jul 03, 2014 11:38 am   Post subject: Re: Mario Help Needed!!

My game is not going to work because there are pictures in my game and thus, it will work when pictures will be available. Still, I will copy and paste my code here.

Turing:

% set the screen to various specific graphics
setscreen ("position:top, center, graphics: 1300, 700,title: Mario, nobuttonbar")

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                            variables
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Variable for the control of keys
var chars : array char of boolean

%Variables for the starting of the game
var firstScreen : int := Pic.FileNew ("Menu.bmp")
var controls : int := Pic.FileNew ("controls.bmp")
var thirdScreen : int := Pic.FileNew ("life3.bmp")
var mygame : int := Pic.FileNew ("mygame.jpg")

%Variable for the game over
var gameOver : int := Pic.FileNew ("gameover.bmp")

%variable for the background of the game
var previous_background : int := Pic.FileNew ("bg1.jpg")
var background : int := Pic.FileNew ("bg.jpg")


%Variable for the coins
var coin_touch : int := 0
var coin_cover : int := 0
var coin_count : int := 0
var coin_show : string

%variables for the Mario

var numFrames1 := Pic.FileNew ("marior.gif")
var numFrames2 := Pic.FileNew ("mariol.gif")
var numFrames3 := Pic.FileNew ("mariour.gif")
var numFrames4 := Pic.FileNew ("marioul.gif")
var game_over := Pic.FileNew ("gameover.bmp")
var sprite := Pic.FileNew ("mariol.gif")
const GROUND_HEIGHT := 78
const RUN_SPEED := 10
const JUMP_SPEED := 33
var GRAVITY := 2

var posx : int := 20
var posy : int := 0
var velx : real := 0
var vely : real := 0

%variables for various other things
var screen_capture : int

%Variables for the screen
var background_x : int := 0
var background_y : int := 0
var moving_speed : int
var framerate : int := 0

%Variables for the movement of screen
const MARGIN : int := 600
var key_count : int := 0

%Variables for other thingd on screen
var fall_down : int := 0
var jump_var : int := 0
var jump_over_tiles := 0
var tile1_y : int
var score : int := 0
var time_var : int := 5200

%Variable for the score menu
var score_menu := Pic.FileNew ("score.bmp")
%variable for the font and the set up the font
var font : int
font := Font.New ("Stencil Std:35:Bold")
var showscore : string
var showtime : string

%Variables for the end of the game
var end_var : int


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Start actual game
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXSTARTING SCREENS OF THE GAMEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


%Draw first screen of the game
Pic.Draw (firstScreen, 0, 0, picMerge)
%Start a loop
loop
    %Wait for an input from the user
    Input.KeyDown (chars)
    %If user press 'ENTER' exit loop
    if chars (KEY_ENTER) then
        exit
    end if
end loop
%claer screen
cls
%Draw secong screen of the game
Pic.Draw (mygame, 0, 0, picMerge)
delay (500)
%Start a loop
loop
    %Clear the screen
    Input.KeyDown (chars)
    if chars (KEY_ENTER) then
        exit
    end if
end loop

%Clear the screen
cls
%Draw third screen of the game
Pic.Draw (controls, 0, 0, picMerge)

%Put a delay of half a second in order for input to work
delay (500)

loop

    %Wait for an input from the user
    Input.KeyDown (chars)
    %If user press 'ENTER' exit loop
    if chars (KEY_ENTER) then
        exit
    end if
end loop
cls

%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXACTUAL GAMEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

setscreen ("offscreenonly")



loop
%When mario will jump on bricks flying in screen, it will check various conditions
    if posx >= 580 and posx <= 620 and posy >= 270 and posy <= 330 then
        posy := 270
        jump_var := 1
        jump_over_tiles := 1
    elsif posx >= 740 and posx <= 930 and posy >= 275 and posy <= 390 then
        posy := 270
        jump_var := 1
        jump_over_tiles := 2
    elsif posx >= 2900 and posx <= 3010 and posy >= 275 and posy <= 330 then
        posy := 270
        jump_var := 1
        jump_over_tiles := 3
    elsif posx >= 3540 and posx <= 3580 and posy >= 275 and posy <= 330 then
        posy := 270
        jump_var := 1
        jump_over_tiles := 4
    elsif posx >= 3760 and posx <= 3840 and posy >= 275 and posy <= 330 then
        posy := 270
        jump_var := 1
        jump_over_tiles := 5
    elsif posx >= 4000 and posx <= 4030 and posy >= 275 and posy <= 330 then
        posy := 270
        jump_var := 1
        jump_over_tiles := 6
    elsif posx >= 4110 and posx <= 4140 and posy >= 275 and posy <= 330 then
        posy := 270
        jump_var := 1
        jump_over_tiles := 7
    elsif posx >= 4220 and posx <= 4250 and posy >= 275 and posy <= 330 then
        posy := 270
        jump_var := 1
        jump_over_tiles := 8
    elsif posx >= 4440 and posx <= 4480 and posy >= 275 and posy <= 330 then
        posy := 270
        jump_var := 1
        jump_over_tiles := 9
    elsif posx >= 4860 and posx <= 4940 and posy >= 275 and posy <= 330 then
        posy := 270
        jump_var := 1
        jump_over_tiles := 10
    elsif posx >= 6340 and posx <= 6480 and posy >= 275 and posy <= 330 then
        posy := 270
        jump_var := 1
        jump_over_tiles := 11
    else
        jump_var := 0
        jump_over_tiles := 0
    end if

    %If mario will jump on blocks, it will stay there
    if posx >= 5110 and posx <= 5220 and posy >= 202 and posy <= 300 then
        posy := 202
        jump_over_tiles := 12
        jump_var := 1
    elsif posx >= 5260 and posx <= 5370 and posy >= 202 and posy <= 300 then
        posy := 202
        jump_over_tiles := 13
        jump_var := 1
    elsif posx >= 5640 and posx <= 5780 and posy >= 202 and posy <= 300 then
        posy := 202
        jump_over_tiles := 14
        jump_var := 1
    elsif posx >= 5830 and posx <= 5930 and posy >= 202 and posy <= 300 then
        posy := 202
        jump_over_tiles := 15
        jump_var := 1
    elsif posx >= 6930 and posx <= 7180 and posy >= 260 and posy <= 400 then
        posy := 260
        jump_over_tiles := 16
        jump_var := 1
    end if

    %How to use Keyboard keys
    Input.KeyDown (chars)
%Left Key
    if chars (KEY_LEFT_ARROW) then
        velx := -RUN_SPEED
        key_count := key_count - 1
        sprite := numFrames2
        key_count -= 1
        %Right Key
    elsif chars (KEY_RIGHT_ARROW) then
        velx := RUN_SPEED
        key_count := key_count + 1
        sprite := numFrames1
        key_count += 1
    else
        velx := 0
    end if


%Mario cannot pass through flying bricks because of the following conditions
if jump_over_tiles = 2 and chars (KEY_UP_ARROW) and posy = 270 and posx >= 750 and posx <= 920 then
        posy := 395
        jump_over_tiles := 0
    elsif jump_over_tiles = 3 and chars (KEY_UP_ARROW) and posy = 270 and posx >= 2910 and posx <= 3000 then
        posy := 395
        jump_over_tiles := 0
    elsif jump_over_tiles = 4 and chars (KEY_UP_ARROW) and posy = 270 and posx >= 3540 and posx <= 3580 then
        posy := 395
        jump_over_tiles := 0
    elsif jump_over_tiles = 5 and chars (KEY_UP_ARROW) and posy = 270 and posx >= 3760 and posx <= 3840 then
        posy := 395
        jump_over_tiles := 0
    elsif jump_over_tiles = 6 and chars (KEY_UP_ARROW) and posy = 270 and posx >= 4000 and posx <= 4030 then
        posy := 395
        jump_over_tiles := 0
    elsif jump_over_tiles = 7 and chars (KEY_UP_ARROW) and posy = 270 and posx >= 4110 and posx <= 4140 then
        posy := 395
        jump_over_tiles := 0
    elsif jump_over_tiles = 8 and chars (KEY_UP_ARROW) and posy = 270 and posx >= 4220 and posx <= 4250 then
        posy := 395
        jump_over_tiles := 0
    elsif jump_over_tiles = 9 and chars (KEY_UP_ARROW) and posy = 270 and posx >= 4440 and posx <= 4480 then
        posy := 395
        jump_over_tiles := 0
    elsif jump_over_tiles = 10 and chars (KEY_UP_ARROW) and posy = 270 and posx >= 4860 and posx <= 4940 then
        posy := 395
        jump_over_tiles := 0
    elsif jump_over_tiles = 11 and chars (KEY_UP_ARROW) and posy = 270 and posx >= 6340 and posx <= 6480 then
        posy := 395
        jump_over_tiles := 0
    elsif jump_over_tiles = 12 and chars (KEY_UP_ARROW) and posy = 250 and posx >= 5100 and posx <= 5230 then
        posy := 395
        jump_over_tiles := 0
    elsif jump_over_tiles = 13 and chars (KEY_UP_ARROW) and posy = 250 and posx >= 5250 and posx <= 5380 then
        posy := 395
        jump_over_tiles := 0
    elsif jump_over_tiles = 14 and chars (KEY_UP_ARROW) and posy = 250 and posx >= 5630 and posx <= 5790 then
        posy := 395
        jump_over_tiles := 0
    elsif jump_over_tiles = 15 and chars (KEY_UP_ARROW) and posy = 250 and posx >= 5820 and posx <= 5940 then
        posy := 395
        jump_over_tiles := 0
    elsif jump_over_tiles = 16 and chars (KEY_UP_ARROW) and posy = 300 and posx >= 6920 and posx <= 7190 then
        posy := 395
        jump_over_tiles := 0

    end if

 %Mario cannot pass through pipes because of the following conditions
    if posx >= 1020 and posx <= 1100 and posy >= 78 and posy <= 150 then
        posx := 1020
    elsif posx <= 1130 and posx >= 1050 and posy >= 78 and posy <= 150 then
        posx := 1130
    elsif posx >= 1400 and posx <= 1490 and posy >= 78 and posy <= 250 then
        posx := 1400
    elsif posx <= 1510 and posx >= 1470 and posy >= 78 and posy <= 250 then
        posx := 1510
    elsif posx >= 1700 and posx <= 1800 and posy >= 78 and posy <= 290 then
        posx := 1700
    elsif posx <= 1820 and posx >= 1750 and posy >= 78 and posy <= 290 then
        posx := 1820
    elsif posx >= 2120 and posx <= 2200 and posy >= 78 and posy <= 290 then
        posx := 2120
    elsif posx <= 2230 and posx >= 2150 and posy >= 78 and posy <= 290 then
        posx := 2230
    elsif posx >= 6130 and posx <= 6200 and posy >= 78 and posy <= 170 then
        posx := 6130
    elsif posx <= 6240 and posx >= 6180 and posy >= 78 and posy <= 170 then
        posx := 6240
    elsif posx >= 6730 and posx <= 6800 and posy >= 78 and posy <= 170 then
        posx := 6730
    elsif posx <= 6850 and posx >= 6750 and posy >= 78 and posy <= 170 then
        posx := 6850
    end if

    %Mario will stay on pipes if it jumps on them because of the following conditions
    if posx >= 1020 and posx <= 1100 and posy >= 150 and posy <= 300 then
        posy := 150
        jump_var:=1
    elsif posx <= 1130 and posx >= 1050 and posy >= 150 and posy <= 300 then
        posy := 150
        jump_var:=1
    elsif posx >= 1400 and posx <= 1490 and posy >= 250 and posy <= 400 then
        posy := 250
        jump_var:=1
    elsif posx <= 1510 and posx >= 1470 and posy >= 250 and posy <= 400 then
        posy := 250
        jump_var:=1
    elsif posx >= 1700 and posx <= 1800 and posy >= 290 and posy <= 450 then
        posy := 290
        jump_var:=1
    elsif posx <= 1820 and posx >= 1750 and posy >= 290 and posy <= 450 then
        posy := 290
        jump_var:=1
    elsif posx >= 2120 and posx <= 2200 and posy >= 290 and posy <= 450 then
        posy := 290
        jump_var:=1
    elsif posx <= 2230 and posx >= 2150 and posy >= 290 and posy <= 450 then
        posy := 290
        jump_var:=1
    elsif posx >= 6130 and posx <= 6200 and posy >= 170 and posy <= 320 then
        posy := 170
        jump_var:=1
    elsif posx <= 6240 and posx >= 6180 and posy >= 170 and posy <= 320 then
        posy := 170
        jump_var:=1
    elsif posx >= 6730 and posx <= 6800 and posy >= 170 and posy <= 320 then
        posy := 170
        jump_var:=1
    elsif posx <= 6850 and posx >= 6750 and posy >= 170 and posy <= 320 then
        posy := 170
        jump_var:=1
    end if

%If mario will try to pass through various bricks on the ground, it cannot pass through
    if posx >= 5100 and posx <= 5210 and posy >= 78 and posy <= 180 then
        posx := 5100
    elsif posx <= 5230 and posx >= 5150 and posy >= 78 and posy <= 180 then
        posx := 5230
    elsif posx >= 5250 and posx <= 5300 and posy >= 78 and posy <= 180 then
        posx := 5250
    elsif posx <= 5380 and posx >= 5280 and posy >= 78 and posy <= 180 then
        posx := 5380
    elsif posx >= 5630 and posx <= 5750 and posy >= 78 and posy <= 180 then
        posx := 5630
    elsif posx <= 5790 and posx >= 5690 and posy >= 78 and posy <= 180 then
        posx := 5380
    elsif posx >= 5820 and posx <= 5915 and posy >= 78 and posy <= 180 then
        posx := 5820
    elsif posx <= 5940 and posx >= 5850 and posy >= 78 and posy <= 180 then
        posx := 5940
    elsif posx >= 6920 and posx <= 7100 and posy >= 78 and posy <= 200 then
        posx := 6920
    elsif posx <= 7190 and posx >= 6940 and posy >= 78 and posy <= 200 then
        posx := 7190
    end if

    % Change value of variables when up arrow key is pressed in order to jump
    if chars (KEY_UP_ARROW) and posy = GROUND_HEIGHT then
        vely := JUMP_SPEED
    end if

    % subtract gravity constant from the velocity EACH frame
    if jump_var = 1 then
        GRAVITY := 0
    elsif jump_var = 0 then
        GRAVITY := 2
    end if
    vely -= GRAVITY
    posx += round (velx)
    posy += round (vely)


    % Simple "collision" check. just makes sure the player stays above ground
    if posy < GROUND_HEIGHT then
        posy := GROUND_HEIGHT
        vely := 0
    end if

%These conditions will help screen move as mario move
    if posx - background_x < MARGIN then
        background_x := posx - MARGIN
    end if
    if (posx + (Pic.Width (numFrames1))) - background_x > maxx - MARGIN then
        background_x := posx + (Pic.Width (numFrames1)) - maxx + MARGIN
    end if

%If Mario will jump over the bricks on ground, the Mario will stay there
if posx >= 740 and posx <= 930 and posy >= 180 and posy <= 270 then
        posy := 180
    elsif posx >= 2900 and posx <= 3010 and posy >= 180 and posy <= 270 then
        posy := 180
    elsif posx >= 3540 and posx <= 3580 and posy >= 180 and posy <= 270 then
        posy := 180
    elsif posx >= 3760 and posx <= 3840 and posy >= 180 and posy <= 270 then
        posy := 180
    elsif posx >= 4000 and posx <= 4030 and posy >= 180 and posy <= 270 then
        posy := 180
    elsif posx >= 4110 and posx <= 4140 and posy >= 180 and posy <= 270 then
        posy := 180
    elsif posx >= 4220 and posx <= 4250 and posy >= 180 and posy <= 270 then
        posy := 180
    elsif posx >= 4440 and posx <= 4480 and posy >= 180 and posy <= 270 then
        posy := 180
    elsif posx >= 4860 and posx <= 4940 and posy >= 180 and posy <= 270 then
        posy := 180
    elsif posx >= 6340 and posx <= 6480 and posy >= 180 and posy <= 270 then
        posy := 180
    end if


    %Starting and end points of screen
    if posx >= 7940 then
        posx := 7940
    elsif posx <= 20 then
        posx := 20
    end if

    %If he jumps in open space in ground
    if posx >= 2610 and posx <= 2650 and posy = 78 then
        posy := -100
        fall_down := 1
    elsif posx >= 3260 and posx <= 3330 and posy = 78 then
        posy := -100
        fall_down := 2
    elsif posx >= 5790 and posx <= 5820 and posy = 78 then
        posy := -100
        fall_down := 3
    end if


%This will change the face of the Mario if the mario will turn left, right or up
    if chars (KEY_UP_ARROW) and sprite = numFrames1 then
        sprite := numFrames3
    end if
    if sprite = numFrames3 and posy <= 80 then
        sprite := numFrames1
    end if

    if chars (KEY_UP_ARROW) and sprite = numFrames2 then
        sprite := numFrames4
    end if
    if sprite = numFrames4 and posy <= 80 then
        sprite := numFrames2
    end if



%This will Draw a previous backgroud
    Pic.Draw (previous_background, 0, 0, picCopy)
%This will draw real Mario background
    Pic.Draw (background, -background_x, +background_y, picCopy)
%This will draw Mario
    Pic.Draw (sprite, posx - background_x, posy - background_y, picMerge)
    %This will Draw score Mneu
    Pic.Draw (score_menu, 0, 625, picMerge)

    %If time of the game is over then it will exit game
    time_var := time_var - 3
    if time_var <= 0 then
        end_var := 1
        exit
    end if
    %This wil change various integers to string
    showtime := intstr (time_var)
    score := key_count
    if key_count <= 0 then
        score := 0
    end if
    showscore := intstr (score)

    %show coins
    coin_show := intstr (coin_count)

    %Draw various type of text on screen
    Draw.Text ("SCORE: " + showscore, 30, 640, font, brightblue)
    Draw.Text ("COINS: " + coin_show, 500, 640, font, brightblue)
    Draw.Text ("TIME: " + showtime, 900, 640, font, brightblue)
    delay (30)
    %Show everything drawn on the screen
    View.Update


    %Check If Mario touched coins
    if posx >= 260 and posx <= 320 and posy >= 78 and posy <= 78 + 35 then
        coin_touch := 1
    elsif posx >= 320 and posx <= 350 and posy >= 78 and posy <= 78 + 35 then
        coin_touch := 2
    elsif posx >= 350 and posx <= 370 and posy >= 78 and posy <= 78 + 35 then
        coin_touch := 3
    elsif posx >= 780 and posx <= 840 and posy >= 280 and posy <= 280 + 35 then
        coin_touch := 4
    elsif posx >= 870 and posx <= 890 and posy >= 280 and posy <= 280 + 35 then
        coin_touch := 5
    elsif posx >= 1068 and posx <= 1076 and posy >= 78 and posy <= 78 + 35 then
        coin_touch := 6
    elsif posx >= 1230 and posx <= 1290 and posy >= 78 and posy <= 78 + 35 then
        coin_touch := 7
    elsif posx >= 2920 and posx <= 2980 and posy >= 280 and posy <= 280 + 35 then
        coin_touch := 8
    elsif posx >= 4000 and posx <= 4020 and posy >= 280 and posy <= 280 + 35 then
        coin_touch := 9
    elsif posx >= 4120 and posx <= 4140 and posy >= 280 and posy <= 280 + 35 then
        coin_touch := 10
    elsif posx >= 4230 and posx <= 4250 and posy >= 280 and posy <= 280 + 35 then
        coin_touch := 11
    elsif posx >= 4870 and posx <= 4930 and posy >= 280 and posy <= 280 + 35 then
        coin_touch := 12
    elsif posx >= 6390 and posx <= 6450 and posy >= 280 and posy <= 280 + 35 then
        coin_touch := 13
    elsif posx >= 6990 and posx <= 7050 and posy >= 260 and posy <= 260 + 35 then
        coin_touch := 14
    elsif posx >= 7040 and posx <= 7100 and posy >= 260 and posy <= 260 + 35 then
        coin_touch := 15
    end if

    %This will update the value of coins when Mario touch coins
    if coin_touch = 1 then
        coin_count += 1
        coin_touch := 0
    elsif coin_touch = 2 then
        coin_count += 1
        coin_touch := 0
    elsif coin_touch = 3 then
        coin_count += 1
        coin_touch := 0
    elsif coin_touch = 4 then
        coin_count += 1
        coin_touch := 0
    elsif coin_touch = 5 then
        coin_count += 1
        coin_touch := 0
    elsif coin_touch = 6 then
        coin_count += 1
        coin_touch := 0
    elsif coin_touch = 7 then
        coin_count += 1
        coin_touch := 0
    elsif coin_touch = 8 then
        coin_count += 1
        coin_touch := 0
    elsif coin_touch = 9 then
        coin_count += 1
        coin_touch := 0
    elsif coin_touch = 10 then
        coin_count += 1
        coin_touch := 0
    elsif coin_touch = 11 then
        coin_count += 1
        coin_touch := 0
    elsif coin_touch = 12 then
        coin_count += 1
        coin_touch := 0
    elsif coin_touch = 13 then
        coin_count += 1
        coin_touch := 0
    elsif coin_touch = 14 then
        coin_count += 1
        coin_touch := 0
    elsif coin_touch = 15 then
        coin_count += 1
        coin_touch := 0
    end if


    %This is if condition if mario jumps in open space
    if fall_down = 1 then
        fall_down := 0
        delay (500)
        posy := 78
        posx := 2540
    elsif fall_down = 2 then
        fall_down := 0
        delay (500)
        posy := 78
        posx := 3180
    elsif fall_down = 3 then
        fall_down := 0
        delay (500)
        posy := 78
        posx := 5550
    end if

    %Ending of the game
    if posx >= 7450 and posx <= 7530 and posy >= 78 and posy <= 600 then
        end_var := 2
        exit
    end if
end loop
%If Player reach the end then do this thing
if end_var = 2 then
    delay (100)
    cls
    Pic.Draw (game_over, 0, 0, picMerge)
    delay (3000)
    cls
    drawfillbox (0, 0, 1300, 700, red)
    colorback (red)
    color (yellow)
    put "Your Score is: ", score
    put skip
    put "Your coins are: ", coin_count
    put skip
    put "That why your Mario value is ", (coin_count / score) * 100
    put skip
    put "Try agian to get to improve your Mario value!!"
    put skip
    put "Good luck"
    %If time is over then do this thing
elsif end_var = 1 then
    delay (100)
    cls
    drawfillbox (0, 0, 1300, 700, red)
    colorback (red)
    color (yellow)
    put "Ohhh!! your game is over"
    put skip
    put "Because your time is over!!"
    put skip
    put "Try again!!"

end if




Mod Edit:
Please wrap your code in either of the following in order to preserve whitespace (indentation) and to highlight the syntax.
code:

[syntax="turing"] ... code ... [/syntax]

[code] ... code ... [/code ]
Zren




PostPosted: Thu Jul 03, 2014 4:43 pm   Post subject: RE:Mario Help Needed!!

Quote:
Coins do not disappear


Basic example of drawing a circle to the screen.

Turing:

type Vector2D :
    record
        x : real
        y : real
    end record

type Coin :
    record
        pos : Vector2D
        radius : real
    end record

var coin : Coin
coin.pos.x := maxx / 2
coin.pos.y := maxy / 2
coin.radius := 10

View.Set ("offscreenonly")
loop
    %--- Logic

    %--- Draw Frame
    cls
   
    % Draw Coin
    Draw.FillOval (round (coin.pos.x), round (coin.pos.y), round (coin.radius), round (coin.radius), black)
   
    View.Update ()
    Time.DelaySinceLast (1000 div 60)
end loop


You need a boolean on/off switch to decide if you want to draw the coin, or if the coin is still available to be "captured".

Turing:

type Vector2D :
    record
        x : real
        y : real
    end record

type Coin :
    record
        pos : Vector2D
        radius : real
        visible : boolean % <--
    end record

var coin : Coin
coin.pos.x := maxx / 2
coin.pos.y := maxy / 2
coin.radius := 10
coin.visible := true  % <--


View.Set ("offscreenonly")
loop
    %--- Logic
   
    % Collision Detection
    if coin.visible then
        % if mario collides with coin
        %    coin.visible := false
        %    score += 1
        % end if
    end if

    %--- Draw Frame
    cls

    % Draw Coin
    if coin.visible then
        Draw.FillOval (round (coin.pos.x), round (coin.pos.y), round (coin.radius), round (coin.radius), black)
    end if

    View.Update ()
    Time.DelaySinceLast (1000 div 60)
end loop


That said, you should probably learn arrays. With them, you can get rid of how much repetitive code you have.

You can find a tutorial on them in The Turing Walkthrough

Turing:

var coins : array 1 .. 10 of Coin

% Initialize all the coins
for i : lower (coins) .. upper (coins)
    coins (i).pos.x := Rand.Int (0, maxx)
    coins (i).pos.y := Rand.Int (0, maxy)
    coins (i).radius := 10
    coins (i).visible := true
end for

% Create a subroutine to draw a coin
proc drawCoin (coin : Coin)
    if coin.visible then
        Draw.FillOval (round (coin.pos.x), round (coin.pos.y), round (coin.radius), round (coin.radius), black)
    end if
end drawCoin

View.Set ("offscreenonly")
loop
    %--- Logic

    % Collision Detection
    for i : lower (coins) .. upper (coins)
        % ...
    end for

    %--- Draw Frame
    cls

    % Draw Coins
    for i : lower (coins) .. upper (coins)
        drawCoin (coins (i))
    end for

    View.Update ()
    Time.DelaySinceLast (1000 div 60)
end loop
Scholar




PostPosted: Mon Jul 07, 2014 7:39 pm   Post subject: RE:Mario Help Needed!!

Your conditionals are making my eyes burn. Is this language really that strict to only allow this kind of arithmetic standard?
Insectoid




PostPosted: Mon Jul 07, 2014 9:27 pm   Post subject: RE:Mario Help Needed!!

No, it's not. Read through the whole thread; OP didn't know what arrays are.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: