Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Sce.Pss.HighLevel.UI;
- namespace SuitePong
- {
- public class Ball
- {
- float x, y, speed, angle, inc_x, inc_y;
- int w, h;
- int min_x, min_y, max_x, max_y;
- public Ball (int min_x, int min_y, int max_x, int max_y){
- this.min_x = min_x;
- this.max_x = max_x;
- this.min_y = min_y;
- this.max_y = max_y;
- this.w = 24;
- this.h = 24;
- reset();
- }
- public void reset(){
- this.x = 960/2 + this.w/2;
- this.y = 544/2 + this.h/2;
- this.speed = 1;
- System.Random random = new System.Random();
- this.angle = (float)(random.NextDouble() * 360);
- this.inc_x = (float)Math.Cos(this.angle);
- this.inc_y = (float)Math.Sin(this.angle);
- //Wait a second?
- //sleep
- }
- public void move(){
- //Move
- this.x += this.inc_x * this.speed;
- this.y += this.inc_y * this.speed;
- //Check limits
- if(this.x < this.min_x)
- this.x = this.min_x;
- if(this.x + this.w > this.max_x)
- this.x = this.max_x - this.w;
- if(this.y < this.min_y)
- this.y = this.min_y;
- if(this.y + this.h > this.max_y)
- this.y = this.max_y - this.h;
- }
- public void blit(ImageBox image){
- image.X = this.x;
- image.Y = this.y;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement