Merge lp:~gustav-hartvigsson/vprocessing/vprocessing_shapes into lp:vprocessing

Proposed by Gustav Hartvigsson
Status: Merged
Approved by: Gustav Hartvigsson
Approved revision: 19
Merged at revision: 8
Proposed branch: lp:~gustav-hartvigsson/vprocessing/vprocessing_shapes
Merge into: lp:vprocessing
Diff against target: 1163 lines (+871/-29)
21 files modified
Makefile (+4/-2)
README (+6/-3)
src/events/clickEvent.vala (+18/-0)
src/mouseEvent.vala (+10/-1)
src/processing.vala (+29/-23)
src/shapes/vButton.vala (+25/-0)
src/shapes/vCircle.vala (+80/-0)
src/shapes/vPolly.vala (+145/-0)
src/shapes/vRect.vala (+93/-0)
src/shapes/vShape.vala (+45/-0)
tests/basic_animation/Makefile (+35/-0)
tests/basic_animation/animation.vala (+68/-0)
tests/basic_animation/main.vala (+11/-0)
tests/basic_animation/run.sh (+1/-0)
tests/shapes/Makefile (+35/-0)
tests/shapes/main.vala (+7/-0)
tests/shapes/shapes.vala (+168/-0)
tests/template/Makefile (+41/-0)
tests/template/foo.vala (+32/-0)
tests/template/main.vala (+17/-0)
tests/template/run.sh (+1/-0)
To merge this branch: bzr merge lp:~gustav-hartvigsson/vprocessing/vprocessing_shapes
Reviewer Review Type Date Requested Status
Gustav Hartvigsson Approve
Review via email: mp+124765@code.launchpad.net

Commit message

Merging...
It has been so meany revisions, it just had to happen...

To post a comment you must log in.
Revision history for this message
Gustav Hartvigsson (gustav-hartvigsson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2012-04-01 19:58:29 +0000
3+++ Makefile 2012-09-17 18:45:28 +0000
4@@ -24,9 +24,11 @@
5 -X -shared
6
7
8-VALAFILES=src/*.vala
9+VALAFILES=src/*.vala\
10+ src/shapes/*.vala\
11+ src/events/*.vala
12
13-EXEC=vProcessing.so
14+EXEC=libvProcessing.so
15
16
17 default:
18
19=== modified file 'README'
20--- README 2012-03-17 11:13:08 +0000
21+++ README 2012-09-17 18:45:28 +0000
22@@ -4,7 +4,7 @@
23
24 FOR LICENSING INFORMATION SEE THE FILE "COPYING".
25
26-THIS SOFTWARE IS USED AT YOUR OWN RISK, ALL AND ANNY MONETARY OR PROPERTY DAMAGE
27+THIS SOFTWARE IS USED AT YOUR OWN RISK, ALL AND ANY MONETARY OR PROPERTY DAMAGE
28 CLAIMS ARE VOID. YOU HAVE BEEN WARNED.
29
30 ==== Compile ====
31@@ -27,8 +27,11 @@
32 make clean
33
34 And to create the documentation run:
35- valadoc src/processing.vala --pkg sdl --pkg sdl-image\
36- --pkg sdl-ttf --pkg sdl-mixer --pkg sdl-gfx -o docs/vProcessing
37+$ mkdir docs
38+$ valadoc src/*.vala --vapidir=/usr/share/vala-0.16/vapi/\
39+ --pkg gee-1.0 --pkg sdl --pkg sdl-image --pkg sdl-ttf\
40+ --pkg sdl-mixer --pkg sdl-gfx -o docs/vProcessing
41+
42
43 This will output the documentation to the folder "docs/vPocessing"
44
45
46=== added directory 'src/events'
47=== added file 'src/events/clickEvent.vala'
48--- src/events/clickEvent.vala 1970-01-01 00:00:00 +0000
49+++ src/events/clickEvent.vala 2012-09-17 18:45:28 +0000
50@@ -0,0 +1,18 @@
51+using GLib;
52+
53+namespace vProcessing {
54+ public interface ClickEvent {
55+ public signal void on_click ();
56+
57+ public abstract void click_event (MouseEvents m);
58+ }
59+
60+ public interface MouseOverEvent {
61+ public signal void on_mouse_over ();
62+ public abstract void mouse_over_event (MouseEvents m);
63+ }
64+
65+ public interface CheckEvent {
66+ public abstract void check_event();
67+ }
68+}
69
70=== modified file 'src/mouseEvent.vala'
71--- src/mouseEvent.vala 2012-04-01 19:58:29 +0000
72+++ src/mouseEvent.vala 2012-09-17 18:45:28 +0000
73@@ -1,14 +1,23 @@
74 namespace vProcessing{
75+
76 /**
77 * This struct just holds some ints to represent where the mouse is, and
78 * if it is clicked.
79 *
80 */
81- public struct mouseEvents {
82+ public struct MouseEvents {
83 int x;
84 int y;
85 int dx;
86 int dy;
87 bool down;
88+
89+ /**
90+ * Returns a Point of where the mouse is.
91+ */
92+ public Point to_point() {
93+ Point p = new Point ((int16) x, (int16) y);
94+ return p;
95+ }
96 }
97 }
98
99=== modified file 'src/processing.vala'
100--- src/processing.vala 2012-04-01 19:58:29 +0000
101+++ src/processing.vala 2012-09-17 18:45:28 +0000
102@@ -13,7 +13,7 @@
103
104 namespace vProcessing{
105
106-
107+ private const int SCREEN_FPS = 200;
108
109 /**
110 * This class is the class that you have to enherrent from to get the
111@@ -25,12 +25,13 @@
112 private bool isRun;
113 private int height = 200;
114 private int width = 200;
115- private unowned SDL.Screen screen;
116+ public unowned SDL.Screen screen;
117 private uint32 myColor;
118 private bool eventBool[322];
119 private SDL.Rect myFillRect;
120+ private uint32 fpsTimer;
121
122- private mouseEvents myMouseEvents;
123+ private MouseEvents myMouseEvents;
124
125 /**
126 * This is where you set all the attributes and add all the valiables that
127@@ -49,7 +50,7 @@
128
129
130 /**
131- * This is where you put the stuff that is goung to be drawn..
132+ * This is where you put the stuff that is going to be drawn..
133 *
134 * use:
135 * {{{
136@@ -61,18 +62,18 @@
137 public abstract void draw();
138
139 /**
140- * lead an image from file.
141+ * load an image from file.
142 *
143 * Unlike in processing (java) loadImage is static, so it can be used
144- * in classes that do not inherret from PApplet.
145+ * in classes that do not inherrent from PApplet.
146 */
147- public static SDL.Surface loadImage(string s) {
148+ public static SDL.Surface load_image(string s) {
149 SDL.Surface tmpImg = SDLImage.load(s);
150 return tmpImg;
151 }
152
153
154- private void initScreen(){
155+ private void init_screen(){
156 uint32 VideoFlags = SurfaceFlag.DOUBLEBUF
157 | SurfaceFlag.HWACCEL
158 | SurfaceFlag.HWSURFACE;
159@@ -86,7 +87,7 @@
160 stderr.printf("Could not initize video \n");
161 }
162 SDL.WindowManager.set_caption("vProcessing","");
163- } //initScreen
164+ } //init_screen
165
166 /**
167 * This sets the size of the screen.
168@@ -100,31 +101,35 @@
169
170 }
171
172- public void DrawRect (int16 x, int16 y, int16 x2, int16 y2) {
173+ public void draw_rect (int16 x, int16 y, int16 x2, int16 y2) {
174 SDLGraphics.Rectangle.fill_color(screen, x, y, x2, y2, myColor);
175 }
176
177- public void DrawCircle (int16 x, int16 y, int16 radius) {
178+ public void draw_circle (int16 x, int16 y, int16 radius) {
179 SDLGraphics.Circle.fill_color(screen, x, y, radius, myColor);
180 }
181
182- public void DrawLine (int16 x, int16 y, int16 x2, int16 y2) {
183+ public void draw_line (int16 x, int16 y, int16 x2, int16 y2) {
184 SDLGraphics.Line.color(screen, x, y, x2, y2, myColor);
185 }
186
187 /**
188- * This is the runner for the pragrame, it will run all the things in setup()
189+ * This is the runner for the programe, it will run all the things in setup()
190 * and continuasly run draw().
191 */
192 public void run() {
193- this.setup();
194 this.isRun = true;
195 this.myColor = this.color_from_rgba(255, 255, 255, 255);
196- this.initScreen();
197+ this.init_screen();
198+ this.setup();
199 while(isRun) {
200+ this.fpsTimer = SDL.Timer.get_ticks();
201 this.process_events();
202 this.draw();
203 this.screen.flip();
204+ if(SDL.Timer.get_ticks() - fpsTimer < 1000/SCREEN_FPS){
205+ SDL.Timer.delay(1000/SCREEN_FPS - (SDL.Timer.get_ticks() - fpsTimer));
206+ }
207 }
208 SDL.quit();
209 }
210@@ -134,11 +139,11 @@
211 screen.fill(myFillRect, 0x0000000);
212 }
213
214- public void setColor(uchar r, uchar g, uchar b, uchar a){
215+ public void set_color(uchar r, uchar g, uchar b, uchar a){
216 this.myColor = this.color_from_rgba(r, g, b, a);
217 }
218
219- public uint32 getColor() {
220+ public uint32 get_color() {
221 return myColor;
222 }
223
224@@ -154,12 +159,12 @@
225 /**
226 * This function return true if the mouse in down.
227 */
228- public bool MouseDown () {
229+ public bool mouse_down () {
230 return myMouseEvents.down;
231 }
232
233 /**
234- * This function returns a mouseEvent structure.
235+ * This function returns a MouseEvent structure.
236 *
237 * Example:
238 * {{{
239@@ -171,7 +176,7 @@
240 * mouseEvents mEvents = this.getMouseEvent()
241 * }}}
242 */
243- public mouseEvents getMouseEvent () {
244+ public MouseEvents get_MouseEvent () {
245 return myMouseEvents;
246 }
247
248@@ -192,10 +197,11 @@
249 myMouseEvents.x = event.motion.x;
250 break;
251 case EventType.MOUSEBUTTONDOWN:
252- /*stdout.printf("clicked\n");*/
253+ stdout.printf("mousedown\n");
254 myMouseEvents.down = true;
255 break;
256 case EventType.MOUSEBUTTONUP:
257+ stdout.printf("mouseup \n");
258 myMouseEvents.down = false;
259 break;
260 case EventType.KEYDOWN:
261@@ -220,9 +226,9 @@
262 }
263
264 /**
265- * This returns an array of bools that con be used to prosses stuff...
266+ * This returns an array of bools that can be used to prosses stuff...
267 */
268- public bool[] getKeyEvent() {
269+ public bool[] get_KeyEvent() {
270 return this.eventBool;
271 }
272
273
274=== added directory 'src/shapes'
275=== added file 'src/shapes/vButton.vala'
276--- src/shapes/vButton.vala 1970-01-01 00:00:00 +0000
277+++ src/shapes/vButton.vala 2012-09-17 18:45:28 +0000
278@@ -0,0 +1,25 @@
279+using GLib;
280+
281+namespace vProcessing {
282+ /**
283+ * vButton derives from vRect and impliments ClickEvent and MouseOverEvent
284+ */
285+ public class vButton : vRect, ClickEvent, MouseOverEvent {
286+ public vButton (int16 x, int16 y, int16 h,int16 w, string s) {
287+ base(x,y,h,w,false);
288+
289+ }
290+
291+ public void click_event (MouseEvents m) {
292+ if ( base.is_inside ( m.to_point () ) && m.down ) {
293+ on_click ();
294+ }
295+ }
296+
297+ public void mouse_over_event (MouseEvents m) {
298+ if ( base.is_inside (m.to_point () ) ) {
299+ on_mouse_over();
300+ }
301+ }
302+ }
303+}
304
305=== added file 'src/shapes/vCircle.vala'
306--- src/shapes/vCircle.vala 1970-01-01 00:00:00 +0000
307+++ src/shapes/vCircle.vala 2012-09-17 18:45:28 +0000
308@@ -0,0 +1,80 @@
309+
310+
311+namespace vProcessing {
312+
313+ /**
314+ * vCircle is a vShape. It represents an ellipse.
315+ * vCircle has one constructor:
316+ * vCircle()
317+ */
318+ public class vCircle : vShape {
319+ /*
320+ * x and y values are inhereted from vShape
321+ */
322+ public int16 rx;
323+ public int16 ry;
324+
325+ private bool filled;
326+
327+ /**
328+ * This is the cosstructor of the class.
329+ * @param x is the x center coordinate of the ellipse.
330+ * @param y is the y center coordinate of the ellipse.
331+ * @param rx is the x axis radius.
332+ * @param ry is the y axis radius.
333+ * @param filled if the ellipse is going to be filled or not.
334+ */
335+ public vCircle (int16 x, int16 y, int16 rx, int16 ry, bool filled) {
336+ this.rx = rx;
337+ this.ry = ry;
338+ this.x = x;
339+ this.y = y;
340+ this.filled = filled;
341+ }
342+
343+ public bool is_inside(Point p) {
344+ if(pointWithinEllipse(this.x, this.y, this.rx, this.ry, p.x, p.y)){
345+ return true;
346+ }
347+ return false;
348+ }
349+
350+ /*
351+ * source: http://board.flashkit.com/board/showthread.php?t=541469
352+ */
353+ private bool pointWithinEllipse (int16 ex ,int16 ey ,int16 ea ,int16 eb ,int16 px ,int16 py ) {
354+
355+ double dx = px - ex;
356+ double dy = py - ey;
357+
358+ double nea = ea;
359+ double neb = eb;
360+
361+ if((dx*dx)/(nea*nea) + (dy*dy)/(neb*neb) <= 1){
362+ return true;
363+ } else {
364+ return false;
365+ }
366+
367+ }
368+
369+
370+ public void draw (SDL.Surface? screen, uint32 color, bool? filled) {
371+ if (filled == null){
372+ if (this.filled) {
373+ SDLGraphics.Ellipse.fill_color(screen, this.x, this.y, this.rx, this.ry, color);
374+ } else {
375+ SDLGraphics.Ellipse.outline_color(screen, this.x, this.y, this.rx, this.ry, color);
376+ }
377+ } else {
378+ if (filled) {
379+ SDLGraphics.Ellipse.fill_color(screen, this.x, this.y, this.rx, this.ry, color);
380+ } else {
381+ SDLGraphics.Ellipse.outline_color(screen, this.x, this.y, this.rx, this.ry, color);
382+ }
383+ }
384+ }
385+
386+ }
387+
388+}
389
390=== added file 'src/shapes/vPolly.vala'
391--- src/shapes/vPolly.vala 1970-01-01 00:00:00 +0000
392+++ src/shapes/vPolly.vala 2012-09-17 18:45:28 +0000
393@@ -0,0 +1,145 @@
394+using SDL;
395+using SDLGraphics;
396+using SDLImage;
397+using SDLMixer;
398+using SDLTTF;
399+using Gee;
400+
401+namespace vProcessing {
402+
403+
404+ /**
405+ * vPolly is a polygon class. it is a vShape.
406+ * vPolly has three connstructors:
407+ * vPolly()
408+ * vPolly.fromArrayOfPoints()
409+ * vPolly.fromArrayListOfPoints()
410+ *
411+ */
412+ public class vPolly : vProcessing.vShape{
413+
414+ /**
415+ * an array to store the points in...
416+ * Probobly needs to be reimplimented to be faster.
417+ */
418+ private ArrayList<Point> myPointArray;
419+
420+ private bool goBack;
421+
422+ /**
423+ * The last poist to be renderd
424+ */
425+ private Point lastPoint;
426+
427+ private Point firstPoint;
428+
429+ /**
430+ * All points that are added are relative to this point.
431+ * This is so that a vPolly can be moved w/o much hassle
432+ */
433+ public vPolly(int16 x, int16 y, bool goBack) {
434+ this.goBack = goBack;
435+ this.x = x;
436+ this.y = y;
437+ myPointArray = new ArrayList<Point>();
438+ }
439+
440+ /**
441+ * This takes an ArrayList of Points to create a shape, it can be used to
442+ * create a vPolly from a predefined shape.
443+ *
444+ */
445+ public vPolly.fromArrayListOfPoints (int16 x, int16 y, bool goBack,
446+ ArrayList<Point> points){
447+ this.goBack = goBack;
448+ this.x = x;
449+ this.y = y;
450+ myPointArray = new ArrayList<Point>();
451+ myPointArray.add_all(points);
452+ }
453+
454+
455+ /**
456+ * This is like vPolly.fromArrayListOfPoints but uses an array of points
457+ * instead.
458+ */
459+ public vPolly.fromArrayOfPoints (int16 x, int16 y, bool goBack,
460+ Point[] points) {
461+ this.x = x;
462+ this.y = y;
463+ this.goBack = goBack;
464+ myPointArray = new ArrayList<Point>();
465+ foreach (Point p in points) {
466+ this.addPointFromPoint (p);
467+ }
468+ }
469+
470+
471+ /**
472+ * Add a point (x and y) to the array.
473+ * note that the order is important.
474+ */
475+ public void addPoint(int16 x, int16 y){
476+ Point tempPoint = new Point(x, y);
477+ myPointArray.add(tempPoint);
478+ }
479+ /**
480+ * This one takes a Point and adds it to the object.
481+ */
482+ public void addPointFromPoint (Point p) {
483+ this.myPointArray.add (p);
484+ }
485+
486+ /**
487+ * Clear the points...
488+ */
489+ public void clearPoints() {
490+ myPointArray.clear();
491+ }
492+
493+ /**
494+ * Draw the array to a surface..
495+ * @param surface The surface that is poing te be draw to.
496+ * @param color The colour of the lines.
497+ * @param goBack if a line is to be put between the last and the first
498+ * point. it can be negeted (null), and will then use the value in the vPolly
499+ * object.
500+ */
501+ public void draw(SDL.Surface? surface, uint32 color, bool? goBack) {
502+ lastPoint = myPointArray.get(0);
503+ firstPoint = lastPoint;
504+ foreach(Point p in myPointArray){
505+ SDLGraphics.Line.color(surface,
506+ lastPoint.x + this.x ,
507+ lastPoint.y + this.y,
508+ p.x + this.x, p.y + this.y,
509+ color
510+ );
511+ lastPoint = p;
512+ }
513+
514+ if(goBack == null) {
515+ if(this.goBack) {
516+ SDLGraphics.Line.color(surface,
517+ lastPoint.x + this.x,
518+ lastPoint.y + this.y,
519+ myPointArray.get(0).x + this.x,
520+ myPointArray.get(0).y + this.y,
521+ color
522+ );
523+ }
524+ } else {
525+ if(goBack) {
526+ SDLGraphics.Line.color(surface,
527+ lastPoint.x + this.x,
528+ lastPoint.y + this.y,
529+ myPointArray.get(0).x + this.x,
530+ myPointArray.get(0).y + this.y,
531+ color
532+ );
533+ }
534+ }
535+ }
536+ }
537+}
538+
539
540=== added file 'src/shapes/vRect.vala'
541--- src/shapes/vRect.vala 1970-01-01 00:00:00 +0000
542+++ src/shapes/vRect.vala 2012-09-17 18:45:28 +0000
543@@ -0,0 +1,93 @@
544+
545+
546+namespace vProcessing {
547+ /**
548+ * this is basicly just has a re implimentation of SDLs rect.
549+ */
550+ public class vRect : vShape{
551+ /*
552+ * x and y values are inhereted from vShape
553+ */
554+ public uint16 h;
555+ public uint16 w;
556+
557+ private bool filled;
558+
559+ public vRect(int16 x, int16 y, uint16 h, uint16 w, bool filled){
560+ this.x = x;
561+ this.y = y;
562+ this.h = h;
563+ this.w = w;
564+ this.filled = filled;
565+ }
566+
567+ public bool is_inside(Point p) {
568+ if(p.x > this.x &&
569+ p.y > this.y &&
570+ p.x < this.x + this.w &&
571+ p.y < this.y + this.h ){
572+ return true;
573+ } else {
574+ return false;
575+ }
576+ }
577+
578+ public bool is_collide(vRect other){
579+
580+ if(this.y >= other.y + other.h || this.y + this.h <= other.y ||
581+ this.x >= other.x + other.w || this.x + this.w <= other.x) {
582+ return false;
583+ }
584+
585+ return true;
586+ }
587+
588+
589+ public void draw (SDL.Surface? screen, uint32 color, bool? filled) {
590+ if (filled == null){
591+ if (this.filled) {
592+ SDLGraphics.Rectangle.fill_color(screen, this.x, this.y,
593+ this.x + (int16)this.w, this.y + (int16)this.h, color);
594+ } else {
595+ SDLGraphics.Rectangle.outline_color(screen, this.x, this.y,
596+ this.x + (int16)this.w, this.y + (int16)this.h, color);
597+ }
598+ } else {
599+ if (filled) {
600+ SDLGraphics.Rectangle.fill_color(screen, this.x, this.y,
601+ this.x + (int16)this.w, this.y + (int16)this.h, color);
602+ } else {
603+ SDLGraphics.Rectangle.outline_color(screen, this.x, this.y,
604+ this.x + (int16)this.w, this.y + (int16)this.h, color);
605+ }
606+ }
607+
608+ }
609+
610+ /*
611+ public static int main(string[] args){
612+ vRect rect1 = new vRect(15, 15, 15, 15);
613+ vRect rect2 = new vRect(25, 25, 15, 15);
614+ vRect rect3 = new vRect(30, 15, 15, 15);
615+
616+ if(rect1.isCollide(rect2)){
617+ stdout.printf("is collide 1 and 2 \n");
618+ } else {
619+ stdout.printf("is not collide 1 and 2 \n");
620+ }
621+
622+ if(rect1.isCollide(rect3)){
623+ stdout.printf("is collide 1 and 3 \n");
624+ } else {
625+ stdout.printf("is not collide 1 and 3 \n");
626+ }
627+
628+ return 0;
629+ }
630+ */
631+
632+ }
633+
634+}
635+
636+
637
638=== added file 'src/shapes/vShape.vala'
639--- src/shapes/vShape.vala 1970-01-01 00:00:00 +0000
640+++ src/shapes/vShape.vala 2012-09-17 18:45:28 +0000
641@@ -0,0 +1,45 @@
642+
643+
644+
645+namespace vProcessing {
646+
647+ /**
648+ * Base class for all shapes in vProcessing
649+ * All use int16!
650+ */
651+ public abstract class vShape {
652+ /*
653+ * All datatypes in shapes MUST be int16!
654+ */
655+ protected int16 x;
656+ protected int16 y;
657+
658+ public void set_x(int16 i) {
659+ this.x = i;
660+ }
661+
662+ public void set_y(int16 i) {
663+ this.y = i;
664+ }
665+
666+ public void set_posision (int16 x, int16 y) {
667+ this.x = x;
668+ this.y = y;
669+ }
670+
671+ public int16 get_x(){
672+ return x;
673+ }
674+
675+ public int16 get_y(){
676+ return y;
677+ }
678+ /*
679+ public abstract void draw(SDL.Screen s);
680+ */
681+ }
682+
683+
684+
685+
686+}
687
688=== added file 'src/shapes/vText.vala'
689=== added directory 'tests'
690=== added directory 'tests/basic'
691=== added directory 'tests/basic_animation'
692=== added file 'tests/basic_animation/Makefile'
693--- tests/basic_animation/Makefile 1970-01-01 00:00:00 +0000
694+++ tests/basic_animation/Makefile 2012-09-17 18:45:28 +0000
695@@ -0,0 +1,35 @@
696+VALAC=valac-0.16
697+VALAFILES=main.vala\
698+ animation.vala
699+VALAPKGS=--pkg glib-2.0\
700+ --pkg vProcessing\
701+ --pkg sdl\
702+ --pkg sdl-gfx\
703+ --pkg sdl-mixer\
704+ --pkg sdl-ttf\
705+ --pkg gee-1.0
706+
707+INCLUDEDIR=./../../
708+CCEXTRA=--vapidir=$(INCLUDEDIR)\
709+ -X -I$(INCLUDEDIR)\
710+ -X -L$(INCLUDEDIR)\
711+ -X -lvProcessing
712+
713+EXEC=main
714+
715+default:
716+ $(VALAC) -o $(EXEC) $(VALAFILES) $(VALAPKGS) $(CCEXTRA)
717+
718+.PHONY: run clean test
719+
720+.IGNORE: run clean test
721+
722+run:
723+ LD_LIBRARY_PATH=LD_LIBRARY_PATH:./../../ ./$(EXEC)
724+
725+clean:
726+ rm $(EXEC)
727+ rm *~
728+
729+test:clean default run
730+
731
732=== added file 'tests/basic_animation/animation.vala'
733--- tests/basic_animation/animation.vala 1970-01-01 00:00:00 +0000
734+++ tests/basic_animation/animation.vala 2012-09-17 18:45:28 +0000
735@@ -0,0 +1,68 @@
736+using GLib;
737+using vProcessing;
738+using SDL;
739+
740+namespace foo {
741+
742+ public class animation : PMain {
743+
744+ private vCircle ball;
745+ private bool down;
746+ private bool left;
747+
748+ private int16 ball_x;
749+ private int16 ball_y;
750+ private int16 ball_offset = 16;
751+
752+ //Constructior
753+ public animation () {
754+ this.size(400, 600);
755+
756+ }
757+
758+ public override void setup () {
759+ ball_x = 50;
760+ ball_y = 25;
761+ left = true;
762+ down = false;
763+ ball = new vCircle (ball_x, ball_y,ball_offset, ball_offset, true);
764+ }
765+
766+ public override void draw () {
767+
768+ this.clear();
769+
770+ if (left) {
771+ ball_x++;
772+ if(ball_x > 600 - ball_offset){
773+ left = false;
774+ }
775+ } else {
776+ ball_x--;
777+ if(ball_x < 0 + ball_offset){
778+ left = true;
779+ }
780+
781+ }
782+
783+ if (down) {
784+ ball_y--;
785+ if(ball_y < 0 + ball_offset){
786+ down = false;
787+ }
788+ } else {
789+ ball_y++;
790+ if(ball_y > 400 - ball_offset){
791+ down = true;
792+ }
793+ }
794+
795+ ball.set_posision(ball_x, ball_y);
796+ this.setColor(255,0,0,255);
797+ ball.draw(this.screen, this.getColor(), null);
798+
799+ }
800+
801+ }
802+
803+}
804
805=== added file 'tests/basic_animation/main.vala'
806--- tests/basic_animation/main.vala 1970-01-01 00:00:00 +0000
807+++ tests/basic_animation/main.vala 2012-09-17 18:45:28 +0000
808@@ -0,0 +1,11 @@
809+using GLib;
810+using vProcessing;
811+using SDL;
812+using foo;
813+
814+int main (string args[]) {
815+
816+ foo.animation a = new foo.animation ();
817+ a.run();
818+ return 0;
819+}
820
821=== added file 'tests/basic_animation/run.sh'
822--- tests/basic_animation/run.sh 1970-01-01 00:00:00 +0000
823+++ tests/basic_animation/run.sh 2012-09-17 18:45:28 +0000
824@@ -0,0 +1,1 @@
825+LD_LIBRARY_PATH=./../../ ./main
826
827=== added directory 'tests/shapes'
828=== added file 'tests/shapes/Makefile'
829--- tests/shapes/Makefile 1970-01-01 00:00:00 +0000
830+++ tests/shapes/Makefile 2012-09-17 18:45:28 +0000
831@@ -0,0 +1,35 @@
832+VALAC=valac-0.16
833+VALAFILES=main.vala\
834+ shapes.vala
835+VALAPKGS=--pkg glib-2.0\
836+ --pkg vProcessing\
837+ --pkg sdl\
838+ --pkg sdl-gfx\
839+ --pkg sdl-mixer\
840+ --pkg sdl-ttf\
841+ --pkg gee-1.0
842+
843+INCLUDEDIR=./../../
844+CCEXTRA=--vapidir=$(INCLUDEDIR)\
845+ -X -I$(INCLUDEDIR)\
846+ -X -L$(INCLUDEDIR)\
847+ -X -lvProcessing
848+
849+EXEC=main
850+
851+default:
852+ $(VALAC) -o $(EXEC) $(VALAFILES) $(VALAPKGS) $(CCEXTRA)
853+
854+.PHONY: run clean test
855+
856+.IGNORE: run clean test
857+
858+run:
859+ LD_LIBRARY_PATH=LD_LIBRARY_PATH:./../../ ./$(EXEC)
860+
861+clean:
862+ rm $(EXEC)
863+ rm *~
864+
865+test:clean default run
866+
867
868=== added file 'tests/shapes/main.vala'
869--- tests/shapes/main.vala 1970-01-01 00:00:00 +0000
870+++ tests/shapes/main.vala 2012-09-17 18:45:28 +0000
871@@ -0,0 +1,7 @@
872+using GLib;
873+
874+int main (string[] args){
875+ test.shapes s = new test.shapes();
876+ s.run();
877+ return 0;
878+}
879
880=== added file 'tests/shapes/shapes.vala'
881--- tests/shapes/shapes.vala 1970-01-01 00:00:00 +0000
882+++ tests/shapes/shapes.vala 2012-09-17 18:45:28 +0000
883@@ -0,0 +1,168 @@
884+using GLib;
885+using SDL;
886+using Gee;
887+using vProcessing;
888+
889+namespace test {
890+ public class shapes : PMain {
891+
892+ private Point[] points;
893+ private vPolly a_polly;
894+ private vPolly b_polly;
895+ private vPolly c_polly;
896+
897+ private int16 xi;
898+ private int16 yi;
899+ private bool goLeft;
900+ private bool goDown;
901+
902+ private bool expand_x;
903+ private bool expand_y;
904+ private int16 expx;
905+ private int16 expy;
906+
907+ private vRect a_rect;
908+ private vRect b_rect;
909+
910+ private vCircle a_circle;
911+ private vCircle b_circle;
912+
913+ public shapes () {
914+ this.size (400, 600);
915+
916+ }
917+
918+ public override void setup () {
919+
920+ this.a_rect = new vRect(560,20,30,20,false);
921+ this.b_rect = new vRect(555,15,30,20,true);
922+ this.xi = 0;
923+ this.yi = 0;
924+ this.goLeft = true;
925+ this.goDown = true;
926+
927+
928+ this.a_circle = new vCircle(150,150,25,10,false);
929+ this.b_circle = new vCircle(300, 300, 150, 100, true);
930+ this.expand_x = false;
931+ this.expand_y = true;
932+ this.expx = 50;
933+ this.expy = 10;
934+
935+ stdout.printf("hello from shapes!\n");
936+
937+ //-----------
938+ points = new Point[7];
939+ stdout.printf("adding points...\n");
940+ //------------
941+ points[0] = new Point(0,0);
942+ points[1] = new Point(50,50);
943+ points[2] = new Point(50,0);
944+ points[3] = new Point(100,0);
945+ points[4] = new Point(100,50);
946+ points[5] = new Point(70,50);
947+ points[6] = new Point(50,70);
948+ //-----------
949+ stdout.printf("done adding points.\n");
950+ stdout.printf("Creating vPolly...\n");
951+ a_polly = new vPolly.fromArrayOfPoints(10,10,false,points);
952+ b_polly = new vPolly.fromArrayOfPoints(100,100,true,points);
953+ c_polly = new vPolly.fromArrayOfPoints(490,10,true,points);
954+
955+ stdout.printf("done creating vPolly\n");
956+ }
957+
958+ public override void draw () {
959+
960+ this.clear();
961+
962+ // ----------
963+
964+ if(goLeft) {
965+ xi++;
966+ } else {
967+ xi--;
968+ }
969+
970+ if (xi >= 600 - 100) {
971+ goLeft = false;
972+ } else if (xi <= 0) {
973+ goLeft = true;
974+ }
975+
976+ if(goDown) {
977+ yi++;
978+ } else {
979+ yi--;
980+ }
981+
982+ if (yi >= 400 - 70) {
983+ goDown = false;
984+ } else if (yi <= 0) {
985+ goDown = true;
986+ }
987+
988+ // ----------
989+
990+ if(this.expand_x) {
991+ this.expx++;
992+ a_circle.rx = expx;
993+ } else {
994+ this.expx--;
995+ a_circle.rx = expx;
996+ }
997+
998+ if(this.expx >= 150) {
999+ this.expand_x = false;
1000+ } else if (this.expx <= 10) {
1001+ this.expand_x = true;
1002+ }
1003+
1004+ if(this.expand_y) {
1005+ this.expy++;
1006+ a_circle.ry = expy;
1007+ } else {
1008+ this.expy--;
1009+ a_circle.ry = expy;
1010+ }
1011+
1012+ if(this.expy >= 150) {
1013+ this.expand_y = false;
1014+ } else if (this.expy <= 10) {
1015+ this.expand_y = true;
1016+ }
1017+
1018+ //-----------
1019+
1020+ this.set_color(255, 255,255,255);
1021+
1022+ b_polly.set_posision(xi, yi);
1023+
1024+ a_polly.draw(this.screen, this.get_color(), null);
1025+ b_polly.draw(this.screen, this.get_color(), null);
1026+ c_polly.draw(this.screen, this.get_color(), null);
1027+
1028+ a_rect.draw(this.screen, this.get_color(), null);
1029+ if(b_rect.is_inside(this.get_MouseEvent().to_point()) && this.mouse_down()) {
1030+ this.set_color(11, 11,255,255);
1031+ } else {
1032+ this.set_color(255, 255,255,255);
1033+ }
1034+
1035+ b_rect.draw(this.screen, this.get_color(), null);
1036+
1037+ this.set_color( (uchar)expy, (uchar)expx, (uchar)expx - (uchar)expy, 255);
1038+
1039+ a_circle.draw(this.screen, this.get_color(), null);
1040+
1041+ this.set_color(150, 150,255,100);
1042+
1043+ if (b_circle.is_inside(this.get_MouseEvent().to_point())){
1044+ b_circle.draw(this.screen, this.get_color(), true);
1045+ } else {
1046+ b_circle.draw(this.screen, this.get_color(), false);
1047+ }
1048+ }
1049+ }
1050+
1051+}
1052
1053=== added directory 'tests/template'
1054=== added file 'tests/template/Makefile'
1055--- tests/template/Makefile 1970-01-01 00:00:00 +0000
1056+++ tests/template/Makefile 2012-09-17 18:45:28 +0000
1057@@ -0,0 +1,41 @@
1058+########################
1059+## THIS FILE IS PUBLIC DOMAIN, AND IS ALLOWD TO USE AS YOU AND/OR OTHER PARTIES
1060+## SEE FIT.
1061+## THIS FILE COMES WETH ABSOLUTLY NO WARRENTY, ALL AND ANNY MONYTARY AND/OR
1062+## PROPERTY CLAIMS ARE VOID.
1063+########################
1064+VALAC=valac-0.16
1065+VALAFILES=main.vala\
1066+ foo.vala
1067+VALAPKGS=--pkg glib-2.0\
1068+ --pkg vProcessing\
1069+ --pkg sdl\
1070+ --pkg sdl-gfx\
1071+ --pkg sdl-mixer\
1072+ --pkg sdl-ttf\
1073+ --pkg gee-1.0
1074+
1075+INCLUDEDIR=./../../
1076+CCEXTRA=--vapidir=$(INCLUDEDIR)\
1077+ -X -I$(INCLUDEDIR)\
1078+ -X -L$(INCLUDEDIR)\
1079+ -X -lvProcessing
1080+
1081+EXEC=main
1082+
1083+default:
1084+ $(VALAC) -o $(EXEC) $(VALAFILES) $(VALAPKGS) $(CCEXTRA)
1085+
1086+.PHONY: run clean test
1087+
1088+.IGNORE: run clean test
1089+
1090+run:
1091+ LD_LIBRARY_PATH=LD_LIBRARY_PATH:./../../ ./$(EXEC)
1092+
1093+clean:
1094+ rm $(EXEC)
1095+ rm *~
1096+
1097+test:clean default run
1098+
1099
1100=== added file 'tests/template/foo.vala'
1101--- tests/template/foo.vala 1970-01-01 00:00:00 +0000
1102+++ tests/template/foo.vala 2012-09-17 18:45:28 +0000
1103@@ -0,0 +1,32 @@
1104+/*
1105+ * THIS FILE IS PUBLIC DOMAIN, AND IS ALLOWD TO USE AS YOU AND/OR OTHER PARTIES
1106+ * SEE FIT.
1107+ * THIS FILE COMES WETH ABSOLUTLY NO WARRENTY, ALL AND ANNY MONYTARY AND/OR
1108+ * PROPERTY CLAIMS ARE VOID.
1109+ */
1110+
1111+using GLib;
1112+using vProcessing;
1113+using SDL;
1114+
1115+namespace foo {
1116+
1117+ public class foo : PMain {
1118+
1119+ //Constructior
1120+ public foo () {
1121+ this.size(400, 600);
1122+ this.run();
1123+ }
1124+
1125+ public override void setup () {
1126+
1127+ }
1128+
1129+ public override void draw () {
1130+
1131+ }
1132+
1133+ }
1134+
1135+}
1136
1137=== added file 'tests/template/main.vala'
1138--- tests/template/main.vala 1970-01-01 00:00:00 +0000
1139+++ tests/template/main.vala 2012-09-17 18:45:28 +0000
1140@@ -0,0 +1,17 @@
1141+/*
1142+ * THIS FILE IS PUBLIC DOMAIN, AND IS ALLOWD TO USE AS YOU AND/OR OTHER PARTIES
1143+ * SEE FIT.
1144+ * THIS FILE COMES WETH ABSOLUTLY NO WARRENTY, ALL AND ANNY MONYTARY AND/OR
1145+ * PROPERTY CLAIMS ARE VOID.
1146+ */
1147+using GLib;
1148+using vProcessing;
1149+using SDL;
1150+using foo;
1151+
1152+int main (string args[]) {
1153+
1154+ foo.foo a = new foo.foo ();
1155+
1156+ return 0;
1157+}
1158
1159=== added file 'tests/template/run.sh'
1160--- tests/template/run.sh 1970-01-01 00:00:00 +0000
1161+++ tests/template/run.sh 2012-09-17 18:45:28 +0000
1162@@ -0,0 +1,1 @@
1163+LD_LIBRARY_PATH=./../../ ./main

Subscribers

People subscribed via source and target branches

to all changes: