News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Duplicate Shapes appearing only as dots

Started by Juha Kämäräinen, January 03, 2009, 06:37:06 PM

Previous topic - Next topic

Juha Kämäräinen

Hey Im trying to use the convexshape i created multiple time on my scene, but it seems like only 1 shape remains 9 other gets turned into single dot.

PlayBASIC Code: [Select]
;CaptureDepth 14
; circle XPOSE4#,YPOSE4#,100,0
DrawShape EGUN,Enemy4X#,Enemy4Y#,1
; drawimage 2,XPOSE4#-10 ,YPOSE4#-10 ,1
; drawimage 3,XPOSE4# ,YPOSE4# ,1

;CaptureDepth 15
; circle XPOSE5#,YPOSE5#,100,0
DrawShape EGUN,Enemy5X#,Enemy5Y#,1
; drawimage 2,XPOSE5#-10 ,YPOSE5#-10 ,1
; drawimage 3,XPOSE5# ,YPOSE5# ,1

;CaptureDepth 16
; circle XPOSE6#,YPOSE6#,100,0
DrawShape EGUN,Enemy6X#,Enemy6Y#,1
; drawimage 2,XPOSE6#-10 ,YPOSE6#-10 ,1
; drawimage 3,XPOSE6# ,YPOSE6# ,1

;CaptureDepth 17
; circle XPOSE7#,YPOSE7#,100,0
DrawShape EGUN,Enemy7X#,Enemy7Y#,1
; drawimage 2,XPOSE7#-10 ,YPOSE7#-10 ,1
; drawimage 3,XPOSE7# ,YPOSE7# ,1




I cant post the whole thing its kinda big.
The point is they are randomised positions when game begins. I dont know is it the first or last one that remains normal convex shape as i designed it.

There is only 1 shape.. My  EGUN  shape so duplicates are turned into single dots... does it have something to do with the world or something... duhh...
Check out my comic - Bujercon 1

kevin

#1
 How are we meant to help without seeing the bit of that demonstrates the fault ?  Were not mind readers you know :)

This example looks like it works to me.


PlayBASIC Code: [Select]
 Cam=NewCamera()
Shape=NewConvexShape(100,5)

do
capturetoscene
clsscene

rotateshape shape,angle#,1
drawshape shape,100,200,2

rotateshape shape,0,2
drawshape shape,400,200,2

drawcamera cam

angle#=angle#+1

Sync
loop



Juha Kämäräinen

#2
Thanks for reply Kevin :)
Well guess i have to post my whole code then  :'(

Hopefully people dont rip off anything, anyway you have to create background image at the size of 2048x2048
Or just stop it from drawing it. Seems like the error is there without the background too.


Also stop the musics from loading... i doubt that has any effect on drawing, but you cant make it work else.

I have been able to make those shapes work if i did new program and assigned accurate positions to them. So it seems like it is possible to draw the same shape multiple times, but something is weird.

Oh and i have been able to locate that in my code it is actually the first shape that gets drawn and duplicates that come afterwards are turned into single dot.


PlayBASIC Code: [Select]
;-flush music from memory----------
;----------------------------------
;-flush images from memory---------
;----------------------------------
;-flush sounds from memory---------
;----------------------------------
;-flush sprites from memory--------
deleteallmusics
deleteallimages
deleteallsounds
deleteallsprites
;----------------------------------


;-------------------------- Creating mainmenu ---------------------------------
OpenScreen 800,600,32,1
TitleScreen "BDM Prototype"
SetFPS 100

print "loading menumusic"
menumusic=loadnewmusic("music\menu.wav")
playmusic menumusic

;-------Resolution choosing-----------------------------------------------------
Repeat
Cls RGB(0,0,0)
Print "Welcome to Bujercon disposable man Prototype version 1.0"
Print "Choose resolution"
Print "1280,1024 ratio 5:4 press a"
Print "1280,960 ratio 3:2 press b"
Print "1280,1024 ratio 5:4 FULLSCREEN press c"
Print "1280,960 ratio 3:2 FULLSCREEN press d"
Print " press spacebar esc to continue to game "
ThisChr$=Inkey$()


If ThisChr$ = "a"
OpenScreen 1280,1024,32,1
ElseIf ThisChr$ = "b"
OpenScreen 1280,960,32,1
ElseIf ThisChr$ = "c"
OpenScreen 1280,1024,32,2
ElseIf ThisChr$ = "d"
OpenScreen 1280,960,32,2
EndIf

Flushkeys
sync
Until EscKey() Or SpaceKey()
;-------------------------------------------------------------------------------
;------------ New game or load game --------------------------------------------
Flushkeys
Print "new game press N"
Print "load game press L"
sync
waitkey
ClsScene
stopmusic menumusic
;------Create mid point values for X & Y axis ---------------------------------

; Make the Variable XPOS = to the screen width divided by
; two. So it should be in the center of the screen
XPOS# = GetScreenWidth()/2
PlayerX# = 1024
;----------------------- Enemy turret locations 1-10 ---------------------------
Enemy1X# = Rnd(2048)
Enemy2X# = Rnd(2048)
Enemy3X# = Rnd(2048)
Enemy4X# = Rnd(2048)
Enemy5X# = Rnd(2048)
Enemy6X# = Rnd(2048)
Enemy7X# = Rnd(2048)
Enemy8X# = Rnd(2048)
Enemy9X# = Rnd(2048)
Enemy10X# = Rnd(2048)
; Make the Variable YPOS = to the screen width divided by
; two. So it should be in the center of the screen
YPOS# = GetScreenHeight()/2
MenuBar1 = GetScreenHeight()-256
MenuBar2 = GetScreenHeight()-192
MenuBar3 = GetScreenHeight()-128
MenuBar4 = GetScreenHeight()-64
PlayerY# = 1024
;----------------------- Enemy turret locations 1-10 ---------------------------
Enemy1Y# = Rnd(2048)
Enemy2Y# = Rnd(2048)
Enemy3Y# = Rnd(2048)
Enemy4Y# = Rnd(2048)
Enemy5Y# = Rnd(2048)
Enemy6Y# = Rnd(2048)
Enemy7Y# = Rnd(2048)
Enemy8Y# = Rnd(2048)
Enemy9Y# = Rnd(2048)
Enemy10Y# = Rnd(2048)

;----------------- Loading everything ----------------------
Print "loading!"
sync
tacticalmusic=loadnewmusic("music\tactical.wav")
playmusic tacticalmusic

;---------background image number is 100, map size 1 pixel is 100meters
;LoadImage "gfx\300kmMAP01.jpg",100
LoadImage "gfx\2048mMAP01.jpg",100

;-------------------------------------------------------------------------------
;---------- Render art to memory -----------------------------------------------
;------------- ------------------------------------------------
;------------ Create player icon------------------------------------------------
;------------ player icon image number 1 ---------------------------------------
CreateImage 1,20,20
RenderToImage 1
circle 10,10,6,0
line 0,10,10,0
line 10,0,20,10
PrepareFXimage 1

;------------ enemy icon image number 2 ----------------------------------------
CreateImage 2,20,20
RenderToImage 2
tri 0,20,10,0,20,20
PrepareFXimage 2

EGUN=GetFreeShape()
CreateConvexShape EGUN,100,16

;---------------------------- Render to screen ---------------------------------
RenderToScreen

;-------------------------------------------------------------------------------
;------------------------------ CREATE WORLD -----------------------------------
CreateWorld 1
CaptureToWorld 1
CreateCamera 1
LimitCamera 1,True
LimitCameraBounds 1,-2048,-2048,2048,2048

;----------- Draw background ---------------------------------------------------
;300kmMAP01.jpg = 20 (3000x3000 pixels wide)
;2048mMAP01.jpg = 20 (2048x2048 pixels wide)
CaptureDepth 100
drawimage 100,0,0,0

;-------------- Draw player icon "house triangle" ------------------------------
CaptureDepth 2
drawimage 1,PlayerX# -10,PlayerY# -10,1

Login required to view complete source code

Check out my comic - Bujercon 1

Juha Kämäräinen

Workaround
Since the duplicates get turned into dots in new revision i made own shape for every enemy so now there are no duplicates.
So i can work with that, but still it would be nice to know so i wont use duplicate shapes anymore.
Check out my comic - Bujercon 1

kevin

#4
 It occurs because the capture is setting the shapes scaling to 0, this was corrected in the PlayBASIC V1.64h4 beta (login required) and above.

However, using Unique shapes is the better option.  


Juha Kämäräinen

Thanks
So guess im using unique shapes. Since the shapes are supposed to be gunrange and when player enters range enemy fires at you.
So i can get hit calculations work better with unique named shape.. Guess it would work with duplicate shapes if i knew how to code it.

Im such a noob when it comes to coding. Anyway when i get the game code finished i will start doing great art for it.



Check out my comic - Bujercon 1