Pixel Plotting Problems
Blitz3D Forums/Blitz3D Beginners Area/Pixel Plotting Problems
| ||
Hi everyone. I need some help with a simple arcadey game im making. Its a game with a black background, and an equally black button you need to find and press. Complete with difficulties that change button size, and click counter, so you know how long it took you to find the button. I know how to do most of this, except for the pixel plotting part of it. I got it to work using the Plot command, and using a very small image with types. (Tried em both to see if the problem im about to tell you would be fixed) The problem is every time i run it, around the same time too. The plotting works fine, for about 20 plots. After that the game starts lagging, until it just stops responding. Heres my code if anyone needs any help. (And it may not look that complete or efficient in some ways, im still working on different aspects but decided to get this working first) Graphics 400,400 SetBuffer BackBuffer() SeedRnd MilliSecs() Global start = 0 Global dot = LoadImage("images/dot.png") Global menu = LoadImage("images/menu PNG.png") cursor = LoadImage("images/cursor.png") ;load buttons Global buttonVE = LoadImage("images/button VE.png") Global buttonE = LoadImage("images/button E.png") Global buttonM = LoadImage("images/button M.png") Global buttonH = LoadImage("images/button H.png") Global buttonSH = LoadImage("images/button SH.png") ;Numbered Difficulty Value Global difficulty = 0 Global randval = 1 Global randval2 = 400 Global buttonX = Rand(5,400) Global buttonY = Rand(5,400) Global buttonW = 0 Global seed = 1 Global seed2 = 10 Global clickval = 1 Global backval = 0 ;menu buttons VE = LoadImage("images/VE.png") E = LoadImage("images/E.png") M = LoadImage("images/M.png") H = LoadImage("images/H.png") SH = LoadImage("images/SH.png") While Not KeyHit(1) If KeyHit(59) Then cheat$ = Input("Enter: ") If cheat$ = "find" Then col = 1 Cls ;Rect 0,0,400,400,1 ElseIf cheat$ = "clear" Cls EndIf EndIf If start = 0 Then ;if very easy is pressed If ImagesOverlap(cursor,MouseX(),MouseY(),VE,27,105) And MouseHit(1) Then difficulty = 1 start = 1 Cls EndIf EndIf If start = 1 Then If difficulty = 1 Then DrawImage buttonVE, 0,0 EndIf Color 255,255,255 ;Rect randval, randval2,50,50,1 ShowPointer() If MouseHit(1) Then Plot MouseX(),MouseY() clickval = clickval + 1 ;ElseIf MouseHit(1) And MouseX() > buttonX And MouseX <buttonX + buttonW And MouseY()>buttonY And MouseY()<buttonY + buttonyH Then ;ClsColor 255,255,255 ;Cls EndIf EndIf If start = 0 Then Cls DrawImage menu,0,0 DrawImage VE,27,105 DrawImage E,230,105 DrawImage M,27,152 DrawImage H,230,152 DrawImage SH,123,225 EndIf If start = 0 Then HidePointer() DrawImage cursor,MouseX(),MouseY() EndIf Flip Wend End Thanks in advance for the help. from, Kevin |
| ||
Some confusing code practices there :o) Aside from your lag problem, which i can't see where that's coming from tbh... Can you upload the images and code together please, so i can run it?If start = 0 Then Cls DrawImage menu,0,0 DrawImage VE,27,105 DrawImage E,230,105 DrawImage M,27,152 DrawImage H,230,152 DrawImage SH,123,225 EndIf If start = 0 Then HidePointer() DrawImage cursor,MouseX(),MouseY() EndIf You have 2 seperate "if start = 0" lines there. For readablity sake, i think it's best if you combine them. Less code to read and more chance of spotting errors :o) So if you can upload the source + images need to run, it would be easier to spot the problem. |
| ||
As for your readability problem, yeah. Theres alot of parts like that. For the last few days ive been moving the code around, trying to get it to work correctly. Once i get it to work, im going to organize it much more. :) Also.. How do i upload stuff? Just post the images in tinypics or something? |
| ||
email me a zip file of the code and the images and ill have a look |
| ||
I looked at the code and could find nothing to indicate a slow-down or lag. Post your hardware list... Processor, memory, video card...the usual stuff. |
| ||
Sorry it took me so long to respond everyone. Ive been buzy this weekend. We had my sisters college graduation, had to drive 3 hours to chico, and 3 hours back. :/ Then yesturday blitz wasnt working for me. @pc tek : I am not sure what he specs are. The computer i was coding on was my family laptop. The most i know for that is that it is a laptop, running vista. Ill transfer the files to MY computer, see if they work and then get back to you. @Ross C and pc Tek: I cant get on the laptop right now because my mom is using it. When she is done ill get back to you both. EDIT: Well on my computer it didnt have that problem. I clicked for a while, and went way past the cut off point. I guess it was just my laptop that was causing the problem. Thanks for your help everyone |