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.

AppGameKit Classic Chat / Create Random Pipe

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 6th Nov 2014 17:43 Edited at: 6th Nov 2014 17:45
Hi.

I want create a game like Floppy Bird that. I made some part with help users in this forum. Now I want make Pipes like attached Picture. I wrote this code for create random pipe sprite. but there is 2 Problem.



1 - I can create pipes at top screen with but can't make them at bottom screen.

2 - when I use create random height with SetSpriteSize (cspr, 8, Random(10,45)), make deform pipe sprite. how can create sprite without deform it?

also I attached My Project for better understand.

Attachments

Login to view attachments
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 6th Nov 2014 18:05
You could use two sprites to make up each section of pipe. One section of pipe that you stretch, and the other for the 'top' or 'bottom' of the pipe that doesn't stretch.

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 6th Nov 2014 18:30 Edited at: 6th Nov 2014 18:33
good idea for create pipes with 2 Piece, but how can join 2 Piece together?

Edit: I attach pipe with 2 Piece.

Attachments

Login to view attachments
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 6th Nov 2014 22:39 Edited at: 7th Nov 2014 08:53
I could problem for make sprite at up and bottom. but still there is 2 Problems.



1- when I use create random height with SetSpriteSize (cspr, 8, Random(10,45)), make deform pipe sprite. how can create sprite without deform it?

2- the space between All Created top pipes and bottom pipes should same.Like Attached Picture.

Attachments

Login to view attachments
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 7th Nov 2014 01:21
Bottom pipe sprite y position = top pipe sprite y position + gap. Let us know how you get on.

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 7th Nov 2014 08:25 Edited at: 7th Nov 2014 09:02
this is your mean?



but this way don't fix space between top and bottom sprites.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 7th Nov 2014 10:04
can anyone help me?
why anyone don't answer me?
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 7th Nov 2014 11:09 Edited at: 7th Nov 2014 11:19
When I did my Flappy clone, I just used double sided pipes - like a large image with 4 pipes, side by side, and an end on each pipe, so it can dangle from the ceiling, stick up from the ground, but also be flipped vertically to provide more variation. I made the pipes large enough to not need to be scaled, scaling a sprite for this is a bad idea, as is using a thousand sprites. Used a handful and re-cycle them as the player progresses through the level.

By using 2 sided pipes, you just have to plonk them along your level - add a pipe at a random height, set the frame randomly from 1 to 4, and flip it around randomly. So for 1 image, you get 8 different pipes that can be used at the top or bottom of the screen. Remember you can flip and mirror sprites - so even if you have highlighting on one side, you can just flip it and it won't look silly because the light source would mostly stay the same. For example the following is a video of Diablo The Prawn - those pipes are stored on a single image and there's only 4 variations of them. Notice that it isn't obvious that there's a restriction, and also that the light source is always on the right hand side. I strongly advise this method, have 4 different pipes, like Greek style columns, tree trunks etc etc - have some fun with it, there are a million Flappy clones already, make yours unique!.

https://www.youtube.com/watch?v=oec_If73h0w

I did this as a standard for other things too, like some swaying seaweed, just did pretty much the exact same thing as with the pipes, used 4 sprites on a single image, random frame number, random flipping, it works very nicely. I just varied the layout of the pipes, some would be a gap inbetween 2 pipes, they'd be rotate randomly from -10 to 10 degrees, some would only stick up from the ground, some would only dangle. Anyway, I found that it allowed for very easy level handling and controlling difficulty was just a matter of reducing the gaps and increasing the speed. I think it's kinda cool to have your level in a way that has never been seen before, and will never be seen again - procedural generation, even on a small scale like in our situation can keep projects interesting - lets face it, nobody on this planet would ever want to design a Flappy Birds level by traditional means.

I did use lower resolution and softened versions of sprites in the distance, as I wanted a kinda underwater, blurry look to things with parallax scrolling and subtle lighting effects. The same technique could be used for trees, backdrop details, clouds, buildings - anything you can think of really.

So anyway, that's what I suggest - draw yourself some pipes, double sided so they can be flipped, and make a good load of sprites from that, like 16, flip them and frame them randomly and re-use them throughout your level. If you concentrate on getting the graphics first then we can always give more specific advice if needed.

I am the one who knocks...
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 7th Nov 2014 11:27 Edited at: 7th Nov 2014 11:27
Thanks Van B But if give an example according your explain is better to understand.

Attachments

Login to view attachments
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 7th Nov 2014 11:34 Edited at: 7th Nov 2014 11:38
Yeah, like that, but the pipe needs to be longer, like imagine if the pipe has to be the same height as the screen. You want to be able to position 2 sprites to produce a gap in the middle, but the rest of the pipe has to cover the area so only the gap is passable.

I'll see if I have any artwork here from Diablo...

I just use that image and set the sprites animation to 256,1024,4 - then set the frame randomly from 1 to 4 - but the main thing is that its a square power of 2 image, and because it has 4 sprites, they can be taller to suit the height of the screen.

I am the one who knocks...

Attachments

Login to view attachments
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 7th Nov 2014 11:50
Van B Please Give Me an Example.
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 7th Nov 2014 11:54
@Behdadsoft - People are very helpful, but sometimes busy, and you cannot expect them to go to a lot of effort to write your program for you!

-- Jim - When is there going to be a release?
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 7th Nov 2014 12:14
why this code don't make any pipe? I used Van B Pipe Image.

Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 7th Nov 2014 12:37
Probably this bit;

Quote: "SetSpriteSize (cspr, 8, Random(1,4))"


You are setting the size of the sprite 8 x 1-4 which would be very very small... In Van's explanation I don't think you should be changing the size of the pipe, but randomly changing the y position of the pipe (so part or all of the pipe is being displayed)...

Something like this (although I'm not sure what you screen resolution is and whether you are using the percentage system, but this should point you in the right direction)...



You should also create cspr as an array of 1000 individual sprites else you will not be able to perform collision detection on each pipe...
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 7th Nov 2014 12:47
Thanks Funnell7. but still show me Blank screen.

here is my full code:

CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 7th Nov 2014 13:29
Funnel7 just said you are sizing the sprite to just a few pixels high and that line is still in your code. Just try removing the line:
SetSpriteSize (cspr, 8, Random(1,4))

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 7th Nov 2014 13:41
with remove this line don't any happen and still show blank screen.
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 7th Nov 2014 13:50
You are not incrementing cspr. This code will make 1 clone.

-- Jim - When is there going to be a release?
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 7th Nov 2014 13:57 Edited at: 7th Nov 2014 14:22
Quote: "You are not incrementing cspr. This code will make 1 clone."


with add inc cspr can fix it. but even if make 1 clone, don't show it.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 7th Nov 2014 14:42 Edited at: 7th Nov 2014 14:48
OK, I fixed Problem and now show me all pipes without deform. but still there is 2 Problem:

1- the space between top and bottom pipes is not same.
2- cspr2 (bottom pipes) don't make random height.mean all height is same. like attached picture.

anyone can help?

this fixed code:

Attachments

Login to view attachments
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 7th Nov 2014 15:42
SetSpritePosition (cspr2, n*30, 80)
is positioning your sprite so the top left corner of the sprite is at position n*30,80. Re-sizing the sprite after that is only stretching it downwards.

Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 7th Nov 2014 15:48 Edited at: 7th Nov 2014 15:48
As CJB has pointed out, you are positioning the sprite at y position 80 for all cspr2 sprites. You want to position the bottom half of the pipe in relation to the first half... Try changing this;

Quote: "SetSpritePosition (cspr2, n*30, 80)"


To something like this;

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 7th Nov 2014 15:59
with use this code still height in all bottom pipes is same. and space between them not same.like attached picture.

Attachments

Login to view attachments
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Nov 2014 16:12
It's good to see that there is no prejudice between pipes and funnels.

OK, I'll leave by the nearest exit...

Quidquid latine dictum sit, altum sonatur
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 7th Nov 2014 16:28 Edited at: 7th Nov 2014 16:28
Behdadsoft> You are not changing the y position of the bottom sprite which is why they all start at the same height. Instead of re-sizing the sprites, just move them into the required positions!

2 seconds, I'll do it for you...

Here:




Personally, i'd change the virtual resolution so you don't need to shrink the sprites down so much, but that's really a preference thing. Good luck!

Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 7th Nov 2014 16:34
Quote: "It's good to see that there is no prejudice between pipes and funnels."


Lol lol lol...
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 7th Nov 2014 16:41
Thanks CJB, fix all problems.

Login to post a reply

Server time is: 2024-05-02 00:38:05
Your offset time is: 2024-05-02 00:38:05