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
Graysire
11
Years of Service
User Offline
Joined: 18th Oct 2013
Location:
Posted: 4th Feb 2014 19:11
sometimes when I click my objects they disappear but sometimes the click doesn\\\'t work. instead I have to click the wall and wait then click back. anything wrong with my code?
rem ore world

sync on : sync rate 60
autocam off
cls 0
load bitmap \\\"E:\\\\Carbonade\\\\images\\\\CarbonAde-splash_template copy.bmp\\\"

ink rgb(0,0,0),0 : set text font \\\"arial\\\" : set text size 14 : set text to bold : set text transparent
center text 320,420,\\\"Developed by Tyler Coleman\\\"
center text 320,434,\\\"Copyright (c) 2013 Starlight Entertainment\\\"

load image \\\"E:\\\\Ore of World Textures\\\\rock2.jpg\\\",6
load image \\\"E:\\\\Ore of World Textures/rock.jpg\\\", 7
load image \\\"E:\\\\Ore of World Textures\\\\copper.jpg\\\",8
REM SOUND EFFECTS

REM SPECIAL EFFECTS
REM REFRESH SCREEN
sync

REM *** INTRO SECTION LOOP

do
REM SCREEN DISPLAY
REM CONTROL INPUT
if Keystate(scancode())=1 then gosub OptionsSection
REM REFRESH SCREEN
sync
loop

REM *** END INTRO SECTION
REM *****************************************

REM *****************************************
REM *** START OPTIONS SECTION
REM *** OPTIONS SECTION HEADER

OptionsSection:
REM DECLARE VARIABLES
REM SCREEN DISPLAY
REM SOUND EFFECTS
REM SPECIAL EFFECTS
REM REFRESH SCREEN

REM *** OPTIONS SECTION LOOP

REM CONTROL INPUT
REM REFRESH SCREEN

REM *** END OPTIONS SECTION
REM *****************************************

REM *****************************************
REM *** START MAIN SECTION 3
REM *** MAIN SECTION HEADER
rem metal level
MainSection:
load dll \\\"c:\\\\windows\\\\system32\\\\user32.dll\\\", 1
clickDelay = call dll(1,\\\"GetDoubleClickTime\\\")
rem variables
clicks = 0
clickStamp = 0
MySpeed=15
Gravity#=0
MyPower=10
csyp=10
csx=250
csy=250
csz=250

cls 0 : backdrop on
rem images
Load image \\\"E:\\\\Carbonade\\\\images\\\\CarbonAde-wall.bmp\\\",2
Load image \\\"E:\\\\Carbonade\\\\images\\\\CarbonAde-wall.bmp\\\",3
Load image \\\"E:\\\\Carbonade\\\\images\\\\CarbonAde-wall.bmp\\\",4
Load image \\\"E:\\\\Carbonade\\\\images\\\\CarbonAde-wall.bmp\\\",5
load image \\\"E:\\\\Ore of World Textures\\\\copper.jpg\\\",8
load image \\\"E:\\\\Ore of World Textures\\\\silver.jpg\\\",9
load image \\\"E:\\\\Ore of World Textures\\\\gold.jpg\\\",10
load image \\\"E:\\\\Ore of World Textures\\\\aluminum.jpg\\\",11
load image \\\"E:\\\\Ore of World Textures\\\\platinum.jpg\\\",12
load image \\\"E:\\\\Ore of World Textures\\\\titanium.jpg\\\",13
load image \\\"E:\\\\Ore of World Textures\\\\tin.jpg\\\",14
rem 250
rem objects

make object cylinder 1,50
scale object 1,100,140,100
position object 1,0,100,0
make object collision box 1,-25,-25,-25,25,25,25,0
rem Walls

rem North Wall
make object box 2,14000,4000,10
rotate object 2,0,0,0
position object 2, 0,2000,7005
texture object 2,2

rem East Wall
make object box 3,14000,4000,10
rotate object 3,0,90,0
position object 3, 7005,2000,0
texture object 3,3

rem North Wall
make object box 4,14000,4000,10
rotate object 4,0,180,0
position object 4, 0,2000,-7005
texture object 4,4

rem West Wall
make object box 5,14000,4000,10
rotate object 5,0,270,0
position object 5, -7005,2000,0
texture object 5,5
set camera range 1,40000

rem Floor
make object box 6,15000,1000,15000 : position object 6,0,-500,0 :
make object collision box 6,-15000,-500,-15000,15000,500,15000,0
texture object 6,6 : scale object texture 6,50,50


S = 250
firstOb = 100 : lastOb = 151
for f = firstOb to lastOb


make object sphere f,250
scale object f, 250, 125, 300

texture object f, 7
position object f,Rnd(13000)-3000,100,Rnd(13000)-3000
yrotate object f,rnd(359)
move object f,100+rnd(100)
make object collision box f,-125,-125,-125,125,125,125,0
next f
OreOb=200 : LOreOb=206
for z = OreOb to LOreOb
make object sphere z,100
next z
TcX# = object position x(129)
TcY# = object position y(129)
TcZ# = object position z(129)
Tsx# = object position x(130)
Tsy# = object position y(130)
Tsz# = object position z(130)
Tgx# = object position x(131)
Tgy# = object position y(131)
Tgz# = object position z(131)
Tax# = object position x(132)
Tay# = object position y(132)
Taz# = object position z(132)
Tpx# = object position x(133)
Tpy# = object position y(133)
Tpz# = object position z(133)
Ttx# = object position x(134)
Tty# = object position y(134)
Ttz# = object position z(134)
Ttix# = object position x(135)
Ttiy# = object position y(135)
Ttiz# = object position z(135)
texture object 200,8
position object 200,Tcx#,TcY#,TcZ#
texture object 201,9
position object 201,Tsx#,TsY#,TsZ#
texture object 202,10
position object 202,Tgx#,TgY#,TgZ#
texture object 203,11
position object 203,Tax#,TaY#,TaZ#
texture object 204,12
position object 204,Tpx#,TpY#,TpZ#
texture object 205,13
position object 205,Ttx#,TtY#,TtZ#
texture object 206,14
position object 206,Ttix#,TtiY#,TtiZ#
do

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)
REM CAMERA ORIENTATIONS
cpX# = camera position X()
cpY# = camera position Y()
cpZ# = camera position Z()
caX# = camera angle X()
caY# = camera angle Y()
caZ# = camera angle Z()


REM LIVE SCREEN DISPLAY
ink rgb(255,255,255),0 : set text size 16 : set text to bold : set text transparent
center text 320,420,\\\"USE ARROW KEYS TO MOVE | PRESS SPACE BAR TO JUMP\\\"
center text 320,440,\\\"PRESS \\\'Q\\\' TO QUIT\\\"
set cursor 0,0






REM CONTROL INPUT

if Spacekey()=1 and MyAcceleration# = 0.0 : rem Make sure I\\\'ve fully landed before I can jump again
P1Y# = P1Y# - Gravity# : rem Look below me
position object 1, P1X#,P1Y#,P1Z# : rem Feel below me
for t = 6 to 6
if object collision(1,t)>0 : rem If feel a solid object below me
MyAcceleration# = MyPower : rem Prepare to jump!

endif
next t
P1Y# = P1Y# + Gravity# : rem Look up
position object 1, P1X#,P1Y#,P1Z# : rem Move back
endif

if KEYSTATE(17)=1 then move object 1,MySpeed
if KEYSTATE(31)=1 then move object 1,0-MySpeed
if KEYSTATE(30)=1 then A1Y = wrapvalue(A1Y-(MySpeed/3))
if KEYSTATE(32)=1 then A1Y = wrapvalue(A1Y+(MySpeed/3))
if upkey()=1 then position object 1,0,100,0
mx = mousex() : my = mousey() : mc = mouseclick()

if rechargetimer = 0
if mc =1
ThisOreOb = pick object (mx,my,OreOb,LOreOb)
endif

if ThisOreOb>0
if mouseclick() = 1 and mflag = 0
mflag = 1
inc clicks
clickStamp = timer()
endif
endif
if mouseclick() = 1 and mflag = 0
mflag = 1
inc clicks
clickStamp = timer()
endif
if mouseclick() = 0 and clicks <> 8 then mflag = 0

T = timer()
if clickStamp + clickDelay < timer() then clicks = 0

if clicks = 8 then delete object ThisOreOb





if mc = 1
thisOb = pick object (mx,my,firstOb,lastOb)


if thisOb>0
if mouseclick() = 1 and mflag = 0
mflag = 1
inc clicks
clickStamp = timer()
endif
if mouseclick() = 0 and clicks <> 2 then mflag = 0

T = timer()
if clickStamp + clickDelay < timer() then clicks = 0

if clicks = 2 then scale object thisOb,250-20,125,250+30

endif
endif
if thisOb>0
if mouseclick() = 1 and mflag = 0
mflag = 1
inc clicks
clickStamp = timer()
endif
if mouseclick() = 0 and clicks <> 3 then mflag = 0

T = timer()
if clickStamp + clickDelay < timer() then clicks = 0

if clicks = 3 then scale object thisOb,250-40,125,250+10

endif

if thisOb>0
if mouseclick() = 1 and mflag = 0
mflag = 1
inc clicks
clickStamp = timer()
endif
if mouseclick() = 0 and clicks <> 4 then mflag = 0

T = timer()
if clickStamp + clickDelay < timer() then clicks = 0

if clicks = 4 then scale object thisOb,250-60,125,250-10

endif

if thisOb>0
if mouseclick() = 1 and mflag = 0
mflag = 1
inc clicks
clickStamp = timer()
endif
if mouseclick() = 0 and clicks <> 5 then mflag = 0

T = timer()
if clickStamp + clickDelay < timer() then clicks = 0

if clicks = 5 then scale object thisOb,250-80,125,250-30

endif

if thisOb>0
if mouseclick() = 1 and mflag = 0
mflag = 1
inc clicks
clickStamp = timer()
endif
if mouseclick() = 0 and clicks <> 6 then mflag = 0

T = timer()
if clickStamp + clickDelay < timer() then clicks = 0

if clicks = 6 then scale object thisOb,250-100,125,250-50

endif
if thisOb>0
if mouseclick() = 1 and mflag = 0
mflag = 1
inc clicks
clickStamp = timer()
endif
if mouseclick() = 0 and clicks <> 7 then mflag = 0

T = timer()
if clickStamp + clickDelay < timer() then clicks = 0

if clicks = 7 then exclude object on thisOb
rechargetimer = 1
endif
endif

if rechargetimer>0 then rechargetimer=rechargetimer-1



if MyAcceleration# = 0.0 : rem If I\\\'m not moving up or down
EmptySpace = 0 : ObjectsChecked = 0 : rem Get ready to start checking collisions
for CheckObject = 100 to 151 : rem Check the floor and every step object
if object collision(1,CheckObject)>0 : rem If I\\\'m touching something
P1Y# = P1Y# - Gravity# : rem Look below me
position object 1, P1X#,P1Y#,P1Z# : rem Feel below me
if object collision(1,CheckObject) = 0 : rem If I feel only air
EmptySpace = EmptySpace + 1 : rem Mark up a free space
endif : rem I\\\'m touching something, but it\\\'s not below me
P1Y# = P1Y# + Gravity# : rem Look up
position object 1, P1X#,P1Y#,P1Z# : rem Move back
else : rem If I\\\'m not touching anything
EmptySpace = EmptySpace + 1 : rem rem Mark up a free space
endif
ObjectsChecked = ObjectsChecked + 1 : rem Done with that one!
next CheckObject : rem On to the next one!
if EmptySpace = ObjectsChecked : rem If I\\\'ve checked all the objects and nothing is below me
MyAcceleration# = MyAcceleration# - Gravity# : rem Gravity begins to pull
endif
endif

if MyAcceleration# <> 0.0 : rem If I\\\'m moving
P1Y# = P1Y# + MyAcceleration# : rem Find where I\\\'m going
position object 1, P1X#,P1Y#,P1Z# : rem Put me there
EmptySpace = 0 : ObjectsChecked = 0 : rem Get ready to start checking collisions
for CheckObject = 100 to 151 : rem Check the floor and every step object
if object collision(1,CheckObject)>0 : rem If I hit an object
P1Y# = P1Y# - MyAcceleration# : rem Find where I was
position object 1, P1X#,P1Y#,P1Z# : rem Put me back
MyAcceleration# = 0.0 : rem Stop me from moving
else : rem If the space I\\\'m going to is just air
EmptySpace = EmptySpace + 1 : rem rem Mark up a free space
endif
ObjectsChecked = ObjectsChecked + 1 : rem Done with that one!
next CheckObject : rem On to the next one!
if EmptySpace = ObjectsChecked : rem If I\\\'ve checked all the objects and nothing is in my path
MyAcceleration# = MyAcceleration# - Gravity# : rem Gravity pulls more
endif
endif



REM TRANSFORM OBJECTS


if object exist(200)=0 then print \\\"Object gone\\\"
print \\\"lastorepick\\\",ThisOreOb
print \\\"LastPick: \\\",thisOb
print \\\"size:\\\",csy
REM MOVE OBJECTS
Yrotate object 1,A1Y

REM CHECK FOR COLLISION
rem Now that I\\\'ve moved, record the new position
P1Xcol# = object position X(1)
P1Zcol# = object position Z(1)

Rem Arena Collision - Keep the player inside the walls

if P1Xcol#<-6900 then P1Xcol#=-6900 : rem If I try to pass through the west wall, find the place I should stay
if P1Zcol#<-6900 then P1Zcol#=-6900 : rem If I try to pass through the south wall, find the place I should stay
if P1Xcol#>6900 then P1Xcol#=6900 : rem If I try to pass through the east wall, find the place I should stay
if P1Zcol#>6900 then P1Zcol#=6900 : rem If I try to pass through the north wall, find the place I should stay

Rem Steps Collision




A1Y# = object angle Y(1) : rem Record the angle I\\\'m facing



REM MOVE CAMERA rem 200
cpZ# = Newzvalue(P1Z#,A1Y-180,10)
cpX# = Newxvalue(P1X#,A1Y-180,10)
if cpX#<-6900 then cpX#=-6900
if cpZ#<-6900 then cpZ#=-6900
if cpX#>6900 then cpX#=6900
if cpZ#>6900 then cpZ#=6900
Position camera cpX#,P1Y#+35,cpZ#
Point camera p1X#,P1Y#+35,P1Z#
REM REFRESH SCREEN

sync


loop
Mobiius
Valued Member
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 4th Feb 2014 22:12
Please use code tags.

[ code ] your code here [ /code ]
(Without spaces of course.)

SamKM
15
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 5th Feb 2014 20:19
It's usually better too if you just post us the part of the code you think is faulty (unless you're really not sure), it helps us solve the problem faster
Graysire
11
Years of Service
User Offline
Joined: 18th Oct 2013
Location:
Posted: 7th Feb 2014 19:00
honestly I have no clue what is making it go wrong, I have messed with collision, didn't fix it and I have done everything else I can think of.
ShellfishGames
12
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 11th Feb 2014 11:48
If you post the code with [code]..[/code]-tags and proper indentation, we might be able to help you out. Regarding the part of the code that doesn't work... since you're not satisfied with the clicking, I'd assume the code handling just that might be of interest here.

So possibly this:



You could tell us what exactly this part of the code is supposed to do, since there is no documentation (i.e. comments or even just self-explanatory variable names) whatsoever in there.
Also, it seems very redundant and there are a lot of "magic numbers" (e.g. "if clicks = 8 then delete object ThisOreOb" - I have no idea where the 8 comes from and what difference it would make if there was a 6 instead of the 8). Whatever this code does, I'd assume it could be reduced to about 20 lines.
Long story short, your code is really hard to debug or even understand. All the more important it is for you to provide us the information needed to help you out instead of posting your whole code (without any formatting) and leaving us with the question whether there's "anything wrong" with it.

Login to post a reply

Server time is: 2025-05-15 20:38:09
Your offset time is: 2025-05-15 20:38:09