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.

2D All the way! / 2d sprite collision in tetris game.

Years of Service
User Offline
Joined: 24th Feb 2003
Posted: 25th Feb 2003 04:40
Hello everyone,
This is the first time i'm asking for help on the forum. I haven't had the need to because I usually find an answer to my question in here already. Here's my question.
I'm creating a clone of tetris. I have the blocks coming down the playing area. Here's my problem. I'm not sure how to write the code that won't let the blocks go to far left, or to far right past the game area. I wanted to use the SPRITE X() command in conjunction with SPRITE COLLISION(), at least that's what I think I need to do. I've looked for examples, tutorials and forums but haven't found a solution yet. I would appreciate any help from anyone. Thank you.


Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 25th Feb 2003 23:12
If the left side is at 30 and the right side 250 use

if block1x < 30 then block1x = 30
if block1x > 250 then block1x = 250

put this before

rem Pasting of sprite game block
sprite (rx), 294 + block1x, 22 + block1y, (rx)

Also you proberly want to put the code below out of the game loop as it doesn't need to be done every loop.

rem Loading of the interface sprite
sprite 20, 0, 0, 8

Login to post a reply

Server time is: 2023-12-03 03:26:32
Your offset time is: 2023-12-03 03:26:32