Break me out

Learn how to start making games.

Break me out

Postby LadyCam » Sat Mar 07, 2015 3:06 am

Hello, can someone help me about the game break out
Help me about the codes :

When I click the space bar I would go to the left or right side wall, here's my code I would like to be random Please I really need Help

Click Actor (Ball)
Click keydown (space)
Script editor

yvelocity = -6;
xvelocity = 6;
bola = 1;

How to be like the game of break out. Please Help me ASAP
Last edited by LadyCam on Wed Mar 11, 2015 5:52 am, edited 2 times in total.
Posts: 1
Joined: Thu Feb 05, 2015 6:39 am
Score: 0 Give a positive score

Re: Break Out game

Postby DjVan » Sat Mar 07, 2015 10:41 am

Welcome to the forum! :D

if you want the ball(actor) direction to be random, you have to make a variable then give it a random number
every time you press space bar with the function rand(x)
first creat a variable on global code, Name it dir

so on actor ball, Key Down (space)
Script Editor :
Code: Select all
dir = rand(2);      // this will creat a random number (0 OR 1)
if(dir == 0){
   xvelocity = -6;    // go to the left
xvelocity = 6         // go to the right
bola = 1;             // no idea..

btw, sometimes the function rand() can be really unfair, it might force you to go right 5 times in a row
in that case you have to find a way to stop the ball-actor from leaving the view.

User avatar
Posts: 24
Joined: Fri May 23, 2014 4:09 pm
Location: Pallet town
Score: 3 Give a positive score

Re: Break me out

Postby bat78 » Sun May 03, 2015 11:53 am

rand() does not return a "random" value but a pseudo-arbitrary one.
A pseudo-arbitrary value can be reversed, because it has been created with mathematical formula that uses the local time as a seed.
Completely random values are hard to get in real life. It must be from a source, that has no logic.

Therefore, the use of rand() makes you a terrible C/C++ programmer.
Not only it is easy-to-reverse (with correlation for instance) but it is also a heavy function.
If you are willing to subdue a High-Quality game you will use a system to base the "randomness" from.

Code: Select all
stTime time = getTime();
int prime_diffusion = !(real_fps % 2);
textNumber = prime_diffusion && !(time.sec % prime_diffusion);
Future of "Project Game-Editor Revival" here
User avatar
Posts: 790
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 83 Give a positive score

Return to Getting Started

Who is online

Users browsing this forum: No registered users and 1 guest