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 / Suggetions For Game In Progress

Author
Message
Kamakazi
14
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: Moberly, Missouri
Posted: 5th Feb 2011 08:17
Hi Everyone...

Not sure where this belongs, but since I'm a newbie still I hope this section will work.

The project I'm working on is called Blast 'Em. The idea of the game is actually a mix between AstroPop (PopCap Games) and Breakout. The object is to give the player a block of a random color (limited to 5 colors at present) and have them shoot it onto the playfield. On the playfield is supposed to be a few blocks; randomly colored and placed. The concept is to match at least three blocks of the same color to remove them. The blocks, however, have a timed drop. And should they reach the paddle then the game is over.

This project has been an idea of mine for a few years now. It started out as a concept for Atari consoles and computers. But...I was needing a project for the current college course I am taking, Writing for Multimedia. This project came to mind and I decided to use it. However, I wasn't expecting to have a prototype working as part of the assignment.

One of the areas I am needing suggestions on is a way to get the blocks on the screen of a random position and color, and keep track of them. One of my original concepts on paper was to use the DIM statement. There are 27 rows with 8 blocks per row so I figured using "DIM GRID(8,27)" would help. I have not attempted to work on this area of the program yet but thought I'd ask the more experienced DBPRO programmers if there is a better solution. Also, this is the first time I've worked with sprites. On the Atari I used simple draw commands with colors to turn them on and the color black to turn them off. Basically, I just moved images.

If this is the wrong area to post this, my apologies. I'll learn eventually. So...any suggestions? Thanks in advance. Screenshot is provided for visuals.

Attachments

Login to view attachments
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 5th Feb 2011 09:58
You're on the right track using an array to store the blocks and their color. The only thing is arrays use zero as well so dimensionalizing an array at 8x27 is really a size of 9x28 because of GRID(0,0).

You don't really have to use sprites here either. You can just use PASTE IMAGE to clear the screen and PASTE IMAGE to position the blocks using the array.

Kamakazi
14
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: Moberly, Missouri
Posted: 5th Feb 2011 10:52
Thanks Grog...

I forgot about the arrays using zero. I had to readjust to 7x27. Thanks for mentioning that or I would have had too many

Here's what I ended up with:



Sorry about the code being in uppercase. It's out of habit. Not bad for my first serious bit of DBPRO programming. Now, I have tried in a simple program before to move an image. The only issue I was having with this was that the image would leave a trail. These blocks are going to have to move down, but not fast and not fluid. The idea is to have the blocks fall like those on the Progressive Mode of Atari's Super Breakout. Drop a full block size and then stop. If it's OK with the MODs here, I'd like to keep updating how this project is going within this thread.
SH4773R
14
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 6th Feb 2011 04:09
it might be a good idea to start a thread in the wip section for your development progress
Kamakazi
14
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: Moberly, Missouri
Posted: 6th Feb 2011 05:46
Thanks Commico! Going to post there now.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 6th Feb 2011 06:56 Edited at: 6th Feb 2011 06:59
Quote: "Sorry about the code being in uppercase. It's out of habit. Not bad for my first serious bit of DBPRO programming. "


It's ok... my Dad insists on typing everything in uppercase too. Yeah, your code looks good but there are a few things you can do to make your code more efficient.

First, you know how to use GOTO so now that you know how it works lets stop using it.

I'm glad you're using .png. Most newbies start out using .jpg which is the worst format for programming. .pngs allow us to use transparencies and they retain the exact colors used to create them (unlike .jpg). You may notice that the bricks look a bit blurry. When you use LOAD IMAGE after the image number add a ,1 as the texture flag to make the images load perfectly without a blur.



When you define an array it starts out with all zeros so the following part of your code isn't needed at all.






The above code snip is kinda flawed. If it picks a zero at any time it starts the whole process over again because the label SETUP: is outside of the FOR/NEXT loop. It'll hang there for a long, long time until it never picks a zero in 20 chances. Instead the random number picking can be changed to a range of 1 to 5 simply by lowering the random number picked and adding a +1 after the RND() command (no IF/THEN check needed). Also INT() isn't needed because the RND() command will only pick an integer.



Instead of using a GOTO if the random grid picked isn't a zero you can wrap it around a REPEAT/UNTIL loop to repeat until a condition is met. In this case it'll repeat until the grid is zero.




Instead of using a bunch of IF/THEN checks to set the coordinates for the bricks you can use the BRICKX and BRICKY variables within the FOR/NEXT loop. Set the starting coordinates at 20,20 and increase the x coordinate by 64 in the column FOR/NEXT and increase the y coordinate by 20 in the row FOR/NEXT. Showing the brick is within the column FOR/NEXT but instead of checking the grid for specific numbers to paste specific images use the grids number as the image number.



Here's the entire edited code:


Quote: "The only issue I was having with this was that the image would leave a trail."


To stop the trail of pasted images clear the screen with a big pasted image (the background) and redraw the grid using the method I showed you.

Kamakazi
14
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: Moberly, Missouri
Posted: 6th Feb 2011 06:58
I think I've hit a road block. I have tried a few ways to get the paddle to "fire" a block into the playfield. Maybe someone here might can suggest something. The code is given below. The few attempts I've tried just don't work. What I end up with are lots of blocks in a row from the paddle. And the block refuses to be placed in a completely empty column. I'm trying to work it in a way that the block before (which would be above it in a grid) it is checked and if one is present then the block fired stays below it and becomes a part of the rest.



I am also including an executable so others can get a better understanding of what it is doing. Everything up to the point of working on a FIRE routine has worked flawlessly. I'm open for suggestions on the Fire routine. Thanks in advance.

Attachments

Login to view attachments
Kamakazi
14
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: Moberly, Missouri
Posted: 6th Feb 2011 08:09
Thanks Grog! That really cleaned up my code work. But, the number stored in the grid is actually a number based on the colored blocks. The logic theory behind the grid is by storing the color number, I'll be able to tell if blocks of three or more together actually match. It was all I could think up during the time I spent working out the project on paper.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 6th Feb 2011 08:16 Edited at: 6th Feb 2011 08:18
I couldn't get the .exe to run at all but I extracted your media from it and ran the newest code snip you posted. What's probably happening is it's placing brick after brick on the same spot because there's no real time delay so it does it many, many times with one keypress. A better delay is using the TIMER() command to slow down the action or prevent a keypress until a certain amount of seconds have gone by. With the TIMER() command 1000 = one second.

Here's a timer with a spacebar delay:


The above won't allow the spacebar to be hit unless at least 500 milliseconds (half a second) have gone by... increase the 500 to 1000 to make it wait a second or a lower number to speed it up.

By the way I love the music on the tile screen ("Deep Fried"). It kinda reminds me of Teenage Mutant Ninja Turtles on the NES which is also cool.

http://www.youtube.com/watch?v=yYWx3vAFi98&feature=related

Kamakazi
14
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: Moberly, Missouri
Posted: 6th Feb 2011 08:26
Thanks again Grog! You ROCK! And thanks for the comment on the Deep Fried. The other track in the game is iffy at this point. I'm still looking for a track that stays close to the Deep Fried.

Couldn't get the EXE to run at all??? Hmmm...was any error messages given?
Kamakazi
14
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: Moberly, Missouri
Posted: 6th Feb 2011 09:14
Here, Grog...see if this EXE works for you. All necessary files are included.

Attachments

Login to view attachments
Kamakazi
14
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: Moberly, Missouri
Posted: 6th Feb 2011 10:21
I managed to fix the fire code to where it doesn't create an error. But it still refuses to place a block in an empty column.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 6th Feb 2011 17:29
It's because if no bricks are found it leaves the FOR/NEXT loop and goes on to the rest of the code (till it hits a return). Add the following under the code you posted last.



I don't have a whole lot of time right now but when I get time I'll clean up your code and get rid of those GOTOs.

Kamakazi
14
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: Moberly, Missouri
Posted: 7th Feb 2011 08:28
Yea...Old ways of programming habits. GOTOs and GOSUBs were friends in the past. By the way...the game is completed enough for now to make my assignment due date. It's a mess though LOL. Here is the new code and a new EXE.



Now I can concentrate more on the tutorials and learn DBPRO better now that I have some free time.

Attachments

Login to view attachments
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 7th Feb 2011 09:16
Quote: "Yea...Old ways of programming habits. GOTOs and GOSUBs were friends in the past."


It's ok. It's hard for some people to stop old habits. I too used GOTO when I started programming in Darkbasic but eventually learned to avoid it. I don't even use GOSUB anymore unless helping people with their code if they use GOSUBs. I only use functions in my own programs.

I still can't get any of your .exes to run.

I like what you've done with the bricks to make them look better. I had just finished my non-GOTO version for you to look at (using the code snip before your last one). I won't go into details about it but if you have questions about the code changes I'm more than happy to answer.



If you haven't already seen them check out TDKs tutorials.

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

Kamakazi
14
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: Moberly, Missouri
Posted: 7th Feb 2011 10:22
Hi Grog...and thanks for the help. Not sure why the EXEs won't run for you. What are your computer's specs? And does the game work by copying and pasting the code and then creating the EXE with DBPRO on your computer?

Also, I tried use the rework you showed me and got two errors. The first one was with:



I keep getting "Could not determine parameter type of 'desktop width()' at line 14." So, I REM'ed it to see what happened next. I got an error stating "Command out of place" at line 255.



I have some free time from assignments now so this will give me something to do to learn DBPRO. Thanks again for all your help.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 7th Feb 2011 20:32
Yeah I'm able to run the code but not the .exes. I'm using Vista 64bit with 4gigs of ram. That's weird... those shouldn't produce errors. Are you totally up to date with Darkbasic Pro?

7.7 Update: http://forum.thegamecreators.com/?m=forum_view&t=180294&b=1

Kamakazi
14
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: Moberly, Missouri
Posted: 8th Feb 2011 05:59
I just bought DBPRO and downloaded it last week so I should be up to date. I'm running Windows 7 64-bit. I remember you mentioning earlier that the images looked fuzzy. The graphics are created for 32-bit color. Then again, I'm running an ATI Raedon. System memory is 2GB.

I have noticed that if the SYNC is used the game will not show any visuals. You will, however, get sounds. When creating the EXE, are there any options I need to look for. Maybe something I am neglecting to do is causing the EXE not to work.
Kamakazi
14
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: Moberly, Missouri
Posted: 8th Feb 2011 09:41
Ok Grog...

I updated my DarkBASIC Professional (and I didn't recognize it at first...thought it was the Free version LOL), opened up the project, and now I can't get the EXE to run either. Weird...the old EXE runs fine after being compiled with the older version of DBPro. Wonder what the difference is.

I'll go over the code and attempt to remove and reduce as I go. Maybe the program is doing something that DBPro wasn't catching before the update.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 8th Feb 2011 09:59
The fuzzyness is probably because you didn't have a texture flag (so it defaulted to zero) which treats images like it's a texture for 3D and blurs the image. Using a texture flag of 1 preserves the image as it was without a blur effect.




When it sees a SYNC that's when it updates the screen. Without a SYNC it'll update the entire screen any time there's a change (even a single pixel). It really helps speed up our programs because it only updates the screen when you want it. When you set the SYNC RATE at 60 it'll always make sure you get 60 frames a second. Setting it to zero raises the frame rate to as fast as the computer running it can handle.

Without SYNC (updates the screen every time a change is made):



With SYNC (updates the screen once after the lines are made):


By the way I attached an .exe of my version of your code.

Attachments

Login to view attachments
Kamakazi
14
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: Moberly, Missouri
Posted: 8th Feb 2011 11:01
I tried to run the application and I get:

"The application was unable to start correctly (0xc0000005)."

Thanks for the tips!
Kamakazi
14
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: Moberly, Missouri
Posted: 8th Feb 2011 11:16
OK...maybe it's my version of Windows or something to do with UAC. I've given DBPRO all access. But one of the error messages given in the output window says:

"Compilation failed (no exe created)"

Any suggestions?
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 8th Feb 2011 17:40
That's interesting I have no idea why I can't run your .exes and you can't run mine. I guess our computers are toxic to each other.

Did you try to run my version of your code after you updated?

Kamakazi
14
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: Moberly, Missouri
Posted: 9th Feb 2011 00:12
Hi Grog...

Yes I did...and it keeps returning the same error shown in my previous post. It's a little frustrating but I'm sure it will get solved. This is why I love programming...creating a program is one part of the problem. The other is all the puzzle solving in making those programs work. In a way, programming is a game by itself.

I'm still slowly going through the code work to clean it up and see if there is something being missed keeping it from working. Oh...and I figured out the compilation error. After the update, DBPRO loaded up my program from a back-up file and erased the original code. Thank goodness I backed it up and was able to copy and paste the code. It's baaa-ack! LOL.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 9th Feb 2011 18:47
Well the easiest way is to post the entire code you have now and I'll help you find the errors.

What I normally do (and several people I know) change the name of the save to add a number at the end (like Program1, Program2, Program3...). That way if the latest version of your code goes horribly wrong you can easily go back to a previous version.

Kamakazi
14
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: Moberly, Missouri
Posted: 10th Feb 2011 16:27
Hi Grog,

I've been up all night reworking the code from scratch. I forgot about having an old laptop with Vista on it. I had just received my copy of DarkGAME Studio on DVD...and Windows 7 kept arguing with me. So, I dragged out the old laptop, set both laptops up side by side, and started the process of cleaning up the code as I transfered. The code may still use some old-fashioned methods, but it is a lot cleaner. Here's the code:



And an EXE can be found here:

http://forum.thegamecreators.com/?m=forum_view&t=181355&b=8

Since this EXE was compiled with a different computer system, see if it will run on your computer.

Login to post a reply

Server time is: 2024-09-29 00:29:51
Your offset time is: 2024-09-29 00:29:51