Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Turtle120902
User Offline
Joined: 25th Jan 2019
Location:
Posted: 6th Mar 2019 18:35
sync on
sync rate 60
autocam off
hide mouse
randomize timer()

Disable escapekey
rem making of menu
gosub mnuvars

do
If selectedItem <> 0
ink white, white
center text screen width()/2, 200, mnuItems$(0)
Else
Ink red, red
center text screen width()/2, 200, mnuItems$(0)
endif
If selectedItem <> 1
ink white, white
center text screen width()/2, 220, mnuItems$(1)
Else
Ink red, red
center text screen width()/2, 220, mnuItems$(1)
endif
If selectedItem <> 2
ink white, white
center text screen width()/2, 240, mnuItems$(2)
Else
Ink red, red
center text screen width()/2, 240, mnuItems$(2)
endif
If selectedItem <> 3
ink white, white
center text screen width()/2, 280, mnuItems$(3)
Else
Ink red, red
center text screen width()/2, 280, mnuItems$(3)
endif
If selectedItem <> 4
ink white, white
center text screen width()/2, 300, mnuItems$(4)
Else
Ink red, red
center text screen width()/2, 300, mnuItems$(4)
endif
If upkey()= 0 and up = 1
up = 0
endif

if upkey() = 1 and up = 0
SelectedItem = SelectedtItem - 1
up = 1
endif

if downkey() = 0 and down = 1
down = 0
endif

if downkey() = 1 and down = 0
SelectedItem = SelectedItem + 1
down = 1
endif

if SelectedItem < 0
SelectedItem = 4
endif
if SelectedItem > 4
SelectedItem = 0
endif

rem exit
if SelectedItem = 4 and returnkey() = 1
end
endif
if SelectedItem = 0 and returnkey() = 1
Goto MainGame
endif
sync

loop

mnuvars:

Dim mnuItems$(5)
mnuItems$(0)= "New Game"
mnuItems$(1)= "Load Game"
mnuItems$(2)= "Save Game"
mnuItems$(3)= "Options"
mnuItems$(4)= "Exit"

SelectedItem = 0
up = 1
down = 0

red = Rgb(255,0,0)
white = Rgb(255,255,255)

Return
`__________________________________________________________________________________
MainGame:

cls

Do

center text screen width()/2, 200, "Welcome to Felipe`s big adventure"
center text screen width()/2, 200, "any key to go to next screen"



do
if scancode() = 0 then exit

loop

do

if keystate( scancode() ) = 1 then goto OptionsSection

sync

loop

OptionsSection:

cls 0
center text screen width()/2, 200, "You are in the olden days and you have to stop a villan"
center text screen width()/2, 200, "any key to go to next screen"


do
if scancode() = 0 then exit
loop

do

if Keystate(scancode())=1 then goto LevelIntroSection



sync
loop
LevelIntroSection:

cls 0
center text screen width()/2, 200, "use the up and down keys to move then to turn camera use left and right keys"
center text screen width()/2, 200, "any key to begin"


do
if scancode() = 0 then exit

loop

do

if Keystate(scancode())=1 then goto begininggame


sync

loop

begininggame:
`DECLARE VARIABLES
`Players
MyScore = 0
`Enemies
`Other
time = 2000
`SCREEN DISPLAY
`REM MAKE LIGHTS HERE

`LOAD IMAGES YOU WILL BE USING IN YOUR GAME

`SCREEN DISPLAY
cls 0
backdrop on

`*********OBJECT CREATION *************************

`Player character - MAIN PLAYER
`load object "models/SS-officer.X",1
make object cylinder 1,50
`color object 1, rgb (255,25,0)
texture object 1,12
position object 1, 0,35,0
scale object 1, 100,140,100



`Walls and floors
make object box 2, 3000,1000,10
`color object 2, rgb (0,255,255)
texture object 2,1
rotate object 2, 0,0,0
position object 2, 0,460,1500

rem east wall-green
make object box 3, 3000,1000,10
`color object 3, rgb (255,99,71)
texture object 3,3
rotate object 3, 0,90,0
position object 3, 1500,460,0

rem south wall-yellow
make object box 4, 3000,1000,10
texture object 4,2
`color object 4, rgb (60,179,113)
rotate object 4, 0,0,0
position object 4, 0,460,-1500

rem west wall-blue
make object box 5, 3000,1000,10
`color object 5, rgb (255,165,0)
texture object 5,4
rotate object 5, 0,-90,0
position object 5, -1500,460,0





rem floor - dark green
make object box 6, 3000,10,3000
`color object 6, rgb(0,128,0)
texture object 6,5
position object 6, 0,-40,0


`Trees and leaves
make object cylinder 7,100
`color object 7, rgb (139,69,19)
texture object 7,6
position object 7, -100,10,-500
scale object 7, 25,175,25

make object cube 8,100
`color object 8, rgb (34,139,34)
texture object 8,7
position object 8, -100,125,-500
scale object 8, 75,75,75

make object cylinder 9,100
`color object 9, rgb (139,69,19)
texture object 9,6
position object 9, 0,10,-400
scale object 9, 25,175,25

make object cube 10,100
` color object 10, rgb (34,139,34)
texture object 10,7
position object 10, 0,125,-400
scale object 10, 75,75,75

make object cylinder 11,100
`color object 11, rgb (139,69,19)
texture object 11,6
position object 11, 100,10,-300
scale object 11, 25,175,25

make object cube 12,100
` color object 12, rgb (34,139,34)
texture object 12,7
position object 12, 100,125,-300
scale object 12, 75,75,75

make object cylinder 13,100
`color object 13, rgb (139,69,19)
texture object 13,6
position object 13, 200,10,-200
scale object 13, 25,175,25

make object cube 14,100
` color object 14, rgb (34,139,34)
texture object 14,7
position object 14, 200,125,-200
scale object 14, 75,75,75

make object cylinder 15,100
`color object 15, rgb (139,69,19)
texture object 15,6
position object 15, 300,10,-100
scale object 15, 25,175,25

make object cube 16,100
` color object 16, rgb (34,139,34)
texture object 16,7
position object 16, 300,125,-100
scale object 16, 75,75,75

make object cylinder 17,100
`color object 17, rgb (139,69,19)
texture object 17,6
position object 17, 400,10,0
scale object 17, 25,175,25

make object cube 18,100
` color object 18, rgb (34,139,34)
texture object 18,7
position object 18, 400,125,0
scale object 18, 75,75,75


make object cylinder 19,100
`color object 20, rgb (139,69,19)
texture object 19,6
position object 19, -100,10,-500
scale object 19, 25,175,25

make object cube 20,100
`color object 21, rgb (34,139,34)
texture object 20,7
position object 20, -100,125,-500
scale object 20, 75,75,75






`Spheres

for s = 30 to 40

make object sphere s, 50
`color object s, rgb (rnd(255),rnd(255),rnd(255))
texture object s, rnd(4)+8
position object s, rnd(950)-rnd(950),50,rnd(950)-rnd(950)

next s

`Enemies


`Pick-ups

`*********************************************************
`SET LIGHTS

make light 25
set light range 25,10000
position light 25, 0,100,0
point light 25, 0,0,0

make light 26
set light range 26, 100000
position light 26, 0,100,0
point light 26, 0,20,0




`SET CAMERA

cpx#=camera position x()
cpy#=camera position y()
cpz#=camera position z()
cax#=camera angle x()
cay#=camera angle y()
caz#=camera angle z()




`REFRESH SCREEN
sync

`********MAIN SECTION LOOP ****************************
do
if scancode() = 0 then exit
loop

do
`OBJECT ORIENTATIONS(PRE-MOVEMENT, PRE-COLLISION)
`Player Character position
P1X# = object position X(1)
P1Y# = object position Y(1)
P1Z# = object position Z(1)
A1X = object angle X(1)
A1Y = object angle Y(1)
A1Z = object angle Z(1)

`If you are using enemies or projectiles, plase their position before movement here

`LIVE SCREEN DISPLAY
`Text
Set Cursor 20, 20
Print "Seconds Left: "; Time/60


center text 320, 440, "USE ARROW KEYS TO MOVE | PRESS Q TO QUIT!"

`CONTROL INPUT
`Acceleration and Pitch of the player
if Upkey()=1 then move object 1, 10
if Downkey()=1 then move object 1, -10
`Turning and banking the player
if Leftkey()=1 then Yrotate object 1, wrapvalue(A1Y-5)
if Rightkey()=1 then Yrotate object 1, wrapvalue(A1Y+5)

`QUIT GAME
if Inkey$() = "q"
for x = 1 to 1000
if object exist(x) = 1 then delete object x
if light exist(x) = 1 then delete light x
next x
backdrop off
goto EndSection
endif

`OBJECT ORIENTATIONS(POST-MOVEMENT, PRE-COLLISION)
`Player Character position
newP1X# = object position X(1)
newP1Y# = object position Y(1)
newP1Z# = object position Z(1)
newA1X = object angle X(1)
newA1Y = object angle Y(1)
newA1Z = object angle Z(1)
`enemies position
`CHECK COLLISSIONS
`Player character - place code for when player collides with
For w = 2 to 20
If Object collision (1,w) > 0 then position Object 1, P1X#,P1Y#,P1Z#
Next w


`Walls
`Enemies
`Pick-Ups
for p = 30 to 40
if object collision (1,p) >0
delete object s
set sound volume 1,100
play sound 1
MyScore = MyScore + 100
exclude object on p
endif
next p

`print score
ink rgb (255,255,255), 0
set cursor 10,10
print "Score = ", MyScore
`Enemies
`Enemies - place code for when enemies collides with
`Walls

`OBJECT ORIENTATIONS(POST-MOVEMENT, POST-COLLISION)
`Player Character position
newP1X# = object position X(1)
newP1Y# = object position Y(1)
newP1Z# = object position Z(1)
newA1X = object angle X(1)
newA1Y = object angle Y(1)
newA1Z = object angle Z(1)

`CHECK PLAYER EXPIRATION

`MOVE CAMERA

Automatic Camera Collision 0, 40, 0

If cpx#>1500 then cpx#=1500
If cpx#<-1500 then cpx#=-1500
If cpz#>1500 then cpz#=1500
If cpz#<-1500 then cpz#=-1500


cpz#=newzvalue(p1z#,a1y-180,200)
cpx#=newxvalue(p1x#,a1y-180,200)
position camera cpx#,p1y#+65,cpz#
point camera p1x#,p1y#+35,p1z#


REM Check Timer
REM Game Not Over - Timer Countdown



if time > 0 then time=time-1
`if game is over
if time=0
for x=1 to 40
if object exist(x)=1 then exclude object on x
next x
backdrop off
gosub LoseSection:
endif

if time > 0 then time = time - 1 : rem timer countdown
if myscore = 1100
for x=1 to 100: rem check all the game object - include all object numbers
if object exist(x) = 1 then delete object x
next x
backdrop off
gosub WinSection
endif

`Play music

Set Music Volume 1, 50
Loop Music 1


`REFRESH SCREEN
sync
loop
`STOP MAIN SECTION


`***************************************************************
` *****************************************
` ***
` *** START END SECTION
`
LoseSection:
cls 0
stop music 1
load bitmap "images/lose screen.bmp"
center text 320,410,"You Lost"
sync
`*** option section loop
`***
do
if scancode() = 0 then exit
loop
do
`CONTROL INPUT
if keystate(scancode()) = 1 then goto EndSection
`REFRESH SCREEN
sync
loop

WinSection:
cls 1
stop music 1
load bitmap "images/win screen.bmp"
center text 320,410,"You won"
sync
`*** option section loop
`***

do
if scancode() = 0 then exit
loop
do
`CONTROL INPUT
if keystate(scancode()) = 1 then goto EndSection
`REFRESH SCREEN
sync
loop
EndSection:
`DECLARE VARIABLES
`SCREEN DISPLAY
stop music 1
`stop music 2
cls 0
ink rgb(255,255,255),0
center text 320,220, "GAME OVER"
center text 320,260, "PLAY AGAIN [Y/N]?"
`SOUND EFFECTS
`SPECIAL EFFECTS
`REFRESH SCREEN
sync
` *** END SECTION LOOP
do
if scancode() = 0 then exit
loop
do
`CONTROL INPUT
if Inkey$() = "y"
goto OptionsSection
endif
if Inkey$() = "n"
cls : end
endif
`REFRESH SCREEN
sync
loop
end
Ortu
DBPro Master
11
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 6th Mar 2019 23:31
Indenting your code will usually make an unclosed nest easily apparent
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
fubarpk
Moderator
14
Years of Service
Recently Online
Joined: 11th Jan 2005
Location: Adelaide
Posted: 17th Apr 2019 15:50
can you please in future place your code in code comment blocks
it makes it much easier to follow
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
locecode
User Offline
Joined: 11th Apr 2019
Location:
Posted: 21st Apr 2019 21:48
You only need one do loop unless there is a selection for menu at the top of your program.

A nest can not close due to programed confusion.

Here is a good structured Program



You can jump to and from one loop from functions or gosub commands.

Look into using functions and arrays.

Login to post a reply

Server time is: 2019-11-12 20:57:01
Your offset time is: 2019-11-12 20:57:01