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 / Sprite not showing up.

Author
Message
Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 23rd Jan 2012 04:34 Edited at: 23rd Jan 2012 05:05
Hi guys, I've been gone for awhile so to get back into programming I decided to do a sidescrolling space shooter type thing, and, as the title says, the player's sprite isn't showing up.



Also if you can help me with the star thing that would be appreciated, I'm pretty sure I got it but I havent gotten to test it yet and some feedback would be nice.

EDIT: WOW! this really does prove I needed a little practice lol, just forgot a sync in the main loop lol. Fail.

-------------------------------------------------------------
Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 23rd Jan 2012 06:04 Edited at: 23rd Jan 2012 06:40
Ok so now get image won't work, it says its an illegal area, and I went in gimp and recorded the top left x and y then the bottom right x and y. (BTW I got a better image online, so I'm using a sprite sheet, I'll attach it.)



Also, I tested my star thing, doesnt work, I'm assuming its because of the repeat until loop I did to keep changing the coordinates of the stars until none overlapped, I did it blindly because I didn't exactly know how to do it. But anyways, any help?

EDIT: Gah! Now it's saying that the image number is illegal, did I do GetFreeImage() wrong?

-------------------------------------------------------------

Attachments

Login to view attachments
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 23rd Jan 2012 08:48 Edited at: 23rd Jan 2012 08:52
Quote: "the player's sprite isn't showing up."

Try either adding SYNC just above the "loop" in your main loop or removing "sync on" from "sync on: sync rate 60", leaving just "sync rate 60"

Quote: "...the repeat until loop I did to keep changing the coordinates of the stars until none overlapped..."

You could just randomly generate coordinates and place them in a DATA statement or a file. However if you want an ever-changing background, there are many better ways to do it. Here's a super-fast method:


Quote: "Gah! Now it's saying that the image number is illegal, did I do GetFreeImage() wrong?"


I dunno abt using a function to find the first available free image slot. 1 small internal error or bad line of code can kill your project. Better off assigning numbers to your sprites:


Quote: " Ok so now get image won't work, it says its an illegal area, and I went in gimp and recorded the top left x and y then the bottom right x and y "

When you LOAD BITMAP, you create a canvas, see CREATE/MAKE BITMAP in the help. So your first coordinate should be startpoint - 1 because generally (dunno abt GIMP) image editors start at 1,1 and DBPRO starts at 0,0. Try decreasing your measurements by 1. Might help.

Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 23rd Jan 2012 17:36 Edited at: 23rd Jan 2012 17:43
Oh ok, so you checked if they we're collided then made it replay instead of checking if they weren't, thanks. Oh yeah and the get image still isn't working, I'm just gonna seperate it from the sprite sheet.

Ugh, I hate having to take the easy way out

EDIT: Do I have a broken version of dbpro? I manual did the image numbers so it would work, but it doesn't.





still getting illegal image number.

EDIT TWO: Uhhh... just ignore that lol, I forgot to global 'energycore'

-------------------------------------------------------------
Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 24th Jan 2012 03:18 Edited at: 24th Jan 2012 04:25
Weird, ok so now I'm making boxes (For a health bar) and grabbing them, but when I paste them it just pastes the same image as the energy core image.



Ok nevermind, I put cls before the second box grab... now it's displaying nothing....

Also, the player isn't showing up.



I don't see why, here's the setupplayer subroutine.



And you have the loadmedia subroutine somewhere on this topic.

Oh yeah, and last one, when I paste all my energy cores one energy core is just randomly on the screen and I don't know how to get it off.

EDIT: Hmmm... I edited my star thing to be like yours but no stars are showing.



(The wait key is for testing)

BTW: There seems to be a bit of a pattern with things not showing up DX
I wish I wasn't gone so long, maybe then I wouldn't need so much help lol.

-------------------------------------------------------------
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 24th Jan 2012 10:17
Quote: "Hmmm... I edited my star thing to be like yours but no stars are showing."


I noticed that you didn't actually grab the final image (Dunno if you just left it out the code you posted or if it is missing in your source). If it is failing to grab the image correctly or producing glitchy results:
Have you performed any other drawing operations before this one, if so it's better to

ie draw it on a separate canvas grab it, delete the canvas. Sometimes drawing operations clash when the screen is used, especially if 3D has been called (sprites included in that category) although the new DBPro compiler hasn't given me that problem so far.

Quote: "Also, the player isn't showing up. "

Try placing the player in the center of the screen at high priority. Could be [lack of] drawing priority causing it.

Could also be that you offset your sprite before mirroring it. Try swapping the MIRROR SPRITE command so it appears before OFFSET SPRITE. When you offset any sprite, it affects all transformations (Which is why it's sometimes better to use good old math to keep your sprite centered during rotation) so it is possibly it affects horizontal/vertical flipping.

Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 25th Jan 2012 01:57 Edited at: 25th Jan 2012 02:40
Thanks! One final (Hopefully) problem, I made this function to move the stars, but it only moves about half of them, and I don't see the problem.



EDIT: Uhh, I did it, turns out that weird energy core thing I couldn't get off was the player... wtf? I made an image and loaded it and stuff, I'm so confused, I'll try and figure this one out for myself, though you're still welcome to help.
EDIT TWO: Fixed it, so ignore the first edit.

-------------------------------------------------------------
Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 28th Jan 2012 03:42
I hate it when no one answers

-------------------------------------------------------------
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 28th Jan 2012 16:10
Quote: "EDIT TWO: Fixed it, so ignore the first edit."

I think everyone thought you meant you had fixed all your problems. Now I can see you meant just "EDIT".

Quote: "I made this function to move the stars"

In what way to you want to move the stars? If you just want to give the illusion of scrolling:

You can apply the same principle to any direction of scrolling. Dunno, if that's what you meant. If not, define "move stars".

Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 31st Jan 2012 03:55
Sorry, didn't have internet for awhile, I have the stars pasted seperately and am just decreasing all of their X values, then when they reach the edge of the screen they are put at the right edge.
I don't understand why some of the stars aren't moving.

-------------------------------------------------------------
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 31st Jan 2012 07:17
Okay looking at your code (which is not easy on my mobile - btw I blame any spelling mistakes in this post on my keypad) it seems you are running some sort of timing system. You're tryna move each star 1 unit per 10 cycles no? Problem is that FOR is desyncronising meaning as your timer increases, so does your target. Better to try:


Hope that helps. If codes buggy, sorry I'm on my phone, but you get the basic idea: whatever timing methid you use, do it outside the star movement.

Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 31st Jan 2012 09:49
Oh wow lol, your code didn't work, but I played around a bit and it turns out I just needed to turn the > into a <



instead of



epik phail.

-------------------------------------------------------------
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 1st Feb 2012 08:52
Quote: "your code didn't work"

It does work, just extremely slowly because I was using a 100ms delay and we're moving 1000 sprites (I was also moving left for some reason, lol - maybe coz I was reading manga before I wrote that). Anyway run this:



You'll notice it still moves slow and is jerky. Moving 1000s of sprites simultaneously is not optimal if it can be avoided. No matter what anyone may say say, using one large image can be better than using many little ones so individual stars or loads of tiles (8x8 tiles vs 720p display) are not always the best idea. Sometimes bigger is better. Sometimes drawing the image in paint first is better.

That is why I suggested using a single background instead of 1k stars. See below (We'll go right in this example):



You can scroll the background faster by subtracting more than one from the positions but you may need three backdrops then (mathematics vs screen width). You can also add variation each level by re-rendering the background. Personally, though for a game in space working with hires (above 800x600), I suggest using textured 3D plains for a backdrop (it really goes fast and you won't be constrained by resolutions either. AR is much easier to work around than res's IMO).

Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 2nd Feb 2012 01:32
Well, it runs just fine and I know how to do that, I could do it pretty easy, so if it starts running slower later in the program I will do that.

-------------------------------------------------------------

Login to post a reply

Server time is: 2024-11-22 05:52:01
Your offset time is: 2024-11-22 05:52:01