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.

Newcomers DBPro Corner / Putting Up borders

Author
Message
ZeroShade
18
Years of Service
User Offline
Joined: 17th Jun 2006
Location:
Posted: 25th Jun 2006 23:13
How would I go about creating a border for a matrix with 10000 by 10000 so that my character does not go outside of the border?

~Live And Let Learn~
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Jun 2006 01:29
Use an imaginary border.

If playerX < 0 then playerX = 0
if playerX > 10000 then playerX = 10000
If playerZ < 0 then playerZ = 0
if playerZ > 10000 then playerZ = 10000

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
ZeroShade
18
Years of Service
User Offline
Joined: 17th Jun 2006
Location:
Posted: 27th Jun 2006 23:20
I thought of that but it didn't work. I'll give you my code... please take a look.
rem **************************
rem ** DEMO **
rem ** Created By: **
rem ** Martin vanPutten **
rem **************************

rem ******************************************************************
rem * # Variables
rem ******************************************************************
rem * player = Player.
rem * PushEnterToBegin = Creates A Wait Period Until ENTER Is Pushed.
rem * playerY = Players Y Value.
rem * x = X Value.
rem * z = Z Value.
rem * cameraX = Cameras X Value.
rem * cameraZ = Cameras Z Value.
rem ******************************************************************

rem ******************************************************************
rem * $ Variables
rem ******************************************************************
rem * player = Your Characters Name.
rem ******************************************************************

rem Setup Introduction.
hide mouse

rem Start Introduction.
cls
center text screen width() / 2, screen height() / 2 - 20, "DEMO"
sleep 1000
center text screen width() / 2, screen height() / 2, "Created By: Martin vanPutten"
sleep 1000
center text screen width() / 2, screen height() / 2 + 20, "Loading"
sleep 5000
cls
center text screen width() / 2, screen height() / 2 - 10, "What is your name?"
set cursor screen width() / 2 - 115, screen height() / 2 + 100
print "..."
set cursor screen width() / 2 - 100, screen height() / 2 + 100
input player$
cls
set cursor screen width() / 2 - 150, screen height() / 2 - 100
print "Welcome to DEMO " ;player$; "!"
set cursor screen width() / 2 - 150, screen height() / 2 - 80
print "This is a brief example of what"
set cursor screen width() / 2 - 150, screen height() / 2 - 60
print "DarkBASIC is capable of. Feel"
set cursor screen width() / 2 - 150, screen height() / 2 - 40
print "free to interact with the objects."
set cursor screen width() / 2 - 150, screen height() / 2 - 20
center text screen width() / 2, screen height() / 2 + 50, "~~Push ENTER To Begin~~"
input PushEnterToBegin#

rem Setup Environment.
show mouse
autocam off
sync on

rem Status Bar
line 20, 250, 16, 280

rem Prepare Ground For The Matrix.
Load bitmap "Ground.bmp", 1
Get Image 1, 1, 1, 128, 128
Delete Bitmap 1

rem Create Ground.
Make Matrix 1, 10000, 10000, 15, 15
Prepare Matrix Texture 1, 1, 1, 1

rem Load Charecter.
load object "idle.x", 1 : append object "walk.x", 1, 100
yrotate object 1, 180 : fix object pivot 1
position object 1, 10000, 5000, 10000
loop object 1, 0, 20 : set object speed 1, 5

rem Game Loop.
do

rem Variables.
playerY# = Object angle Y(1)

rem Player Movement.
stage = 0
if Leftkey() = 1 then player# = player# - 9.0 : player# = wrapvalue(playerY# - 4.5)
if Rightkey() = 1 then player# = player# + 9.0 : player# = wrapvalue(playerY# + 4.5)
if Upkey() = 1 then x# = NewxValue(x#, player#, +12) : z# = NewzValue(z#, player#, +12) : stage = 1
if Downkey() = 1 then x# = NewxValue(x#, player#, -12) : z# = NewzValue(z#, player#, -12) : stage = 1
position object 1, x# + 5000, 0.0, z# + 5000
yrotate object 1, player#

rem Controling Player Animation.
if stage <> oldstage
if stage = 0
set object frame 1, 0.0
loop object 1, 0, 20
set object speed 1, 10
endif
if stage = 1
set object frame 1, 105.0
loop object 1, 105, 125
set object speed 1, 40
endif
oldstage = stage
endif

rem Camera Control.
cameraZ# = Newzvalue(z# + 5000, playerY# - 180, 300)
cameraX# = Newxvalue(x# + 5000, playerY# - 180, 300)
Position Camera cameraX#, 150, cameraZ#
Point camera x# + 5000, 150, z# + 5000

rem Boundaries.
if x < 0 then x = 0
if x > 10000 then x = 10000
if z < 0 then z = 0
if z > 10000 then z = 10000

rem Refresh Screen.
sync

rem End Game Loop.
loop

~Live And Let Learn~
Trinita
21
Years of Service
User Offline
Joined: 29th Sep 2003
Location: Italy
Posted: 29th Jun 2006 01:17
You must change this:



with this:



Place this code before:

position object 1, x# + 5000, 0.0, z# + 5000
yrotate object 1, player#


Bye

"An eye for an eye will only make the whole world blind."

Login to post a reply

Server time is: 2024-11-26 17:34:39
Your offset time is: 2024-11-26 17:34:39