1984年6月6日,《俄罗斯方块》发布。因为由俄罗斯计算工程师,阿列克谢·帕基特诺夫发明而得名。 2007年,《电子游戏月刊》将该游戏列为史上最伟大的100个游戏中的第一位。 网上能找到各种编程语言实现的该游戏,当然少不了ABAP版本,源代码链接:https://github.com/alejogonzaleze/SAP/blob/master/ABAP/Tetris/ZTETRIS
看下游戏画面:
下面是具体创建方式。
主程序代码:
REPORT ztetris NO STANDARD PAGE HEADING.
INCLUDE ztetris_d.
INCLUDE ztetris_f.
INCLUDE ztetris_i.
INCLUDE ztetris_o.
START-OF-SELECTION.
PERFORM init_figures.
PERFORM init_stack.
PERFORM put_next_fig.
SET PF-STATUS 'STATUS_0'.
CALL SCREEN 100.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'UP'
OR 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
AT PF21.
CLEAR: err, count.
DO.
PERFORM fig_move USING 'DOWN' CHANGING err.
IF err EQ 'X'.
EXIT.
ENDIF.
ADD 1 TO count.
ENDDO.
ADD count TO scores.
PERFORM out.
PERFORM f_call_rfc_wait.
AT PF22.
PERFORM fig_move USING 'LEFT' CHANGING err.
PERFORM out.
PERFORM f_call_rfc_wait.
AT PF23.
PERFORM fig_rotate.
PERFORM out.
PERFORM f_call_rfc_wait.
AT PF24.
PERFORM fig_move USING 'RIGHT' CHANGING err.
PERFORM out.
PERFORM f_call_rfc_wait.
AT PF25.
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING new_code = 'PF21'.
LEAVE LIST-PROCESSING.
AT PF26.
PERFORM fig_move USING 'DOWN' CHANGING err.
PERFORM out.
IF err = 'X'.
PERFORM fig_append.
PERFORM check_full_line.
PERFORM put_next_fig.
ENDIF.
PERFORM f_call_rfc_wait.
include ZTETRIS_D 代码:
*----------------------------------------------------------------------*
* INCLUDE ZTETRIS_D *
*----------------------------------------------------------------------*
TYPES: BEGIN OF outtype,
line TYPE char20,
END OF outtype.
DATA outtab TYPE outtype OCCURS 1 WITH HEADER LINE.
TYPES: BEGIN OF figure,
name(10) TYPE c,
width TYPE i,
height TYPE i,
body1 TYPE i,
body2 TYPE i,
body3 TYPE i,
body4 TYPE i,
old_body1 TYPE i,
old_body2 TYPE i,
old_body3 TYPE i,
old_body4 TYPE i,
END OF figure.
DATA: w_1st(2) TYPE i,
size_v TYPE i,
size_h TYPE i,
w1 TYPE i,
w2 TYPE i,
start TYPE i,
shft TYPE i,
shft1 TYPE i,
rnd TYPE i,
ini TYPE i,
count_line TYPE i,
cl TYPE i,
n1 TYPE i,
n2 TYPE i,
ix TYPE i,
s10 TYPE i,
sw TYPE i,
linct TYPE i,
sini TYPE i,
wini TYPE i,
s TYPE i,
w TYPE i,
lc TYPE i,
otstup TYPE i,
row TYPE i,
col TYPE i,
st_width TYPE i VALUE 12,
st_height TYPE i VALUE 20,
count TYPE i,
scores TYPE i.
DATA: stack TYPE c OCCURS 0,
w_col(2) TYPE c,
w_typ(1) TYPE c,
w_nxt(1) TYPE c,
err1 TYPE c,
result(20) TYPE c,
answer(1) TYPE c,
lv_mssg1(80) TYPE c,
lv_mssg2(80) TYPE c,
sz(1) TYPE c,
st(1) TYPE c,
sf(1) TYPE c,
data0(1) TYPE c,
data1(1) TYPE c,
data2(1) TYPE c,
data3(1) TYPE c,
data4(1) TYPE c,
data5(1) TYPE c,
data6(1) TYPE c,
data7(1) TYPE c,
data8(1) TYPE c,
data9(1) TYPE c,
outst(20) TYPE c,
err(1) TYPE c,
fl_new(1) TYPE c,
outstring(100) TYPE c,
so(2) TYPE c.
DATA: square TYPE figure,
line1 TYPE figure,
line2 TYPE figure,
lzz1 TYPE figure,
lzz2 TYPE figure,
rzz1 TYPE figure,
rzz2 TYPE figure,
tri1 TYPE figure,
tri2 TYPE figure,
tri3 TYPE figure,
tri4 TYPE figure,
lgg1 TYPE figure,
lgg2 TYPE figure,
lgg3 TYPE figure,
lgg4 TYPE figure,
rgg1 TYPE figure,
rgg2 TYPE figure,
rgg3 TYPE figure,
rgg4 TYPE figure,
nxt_fig TYPE figure,
cur_fig TYPE figure.
DATA: nxt1(8) TYPE c,
nxt2(8) TYPE c,
nxt3(8) TYPE c,
nxt4(8) TYPE c,
nxt5(8) TYPE c,
nxt6(8) TYPE c.
DATA: stack_fig LIKE stack,
stack_fig_old LIKE stack,
stack_zad LIKE stack,
stack_out LIKE stack,
temp_fig1 LIKE cur_fig,
temp_fig LIKE cur_fig.
ZTETRIS_F 代码:
*---------------------------------------------------------------------*
* INCLUDE ZTETRIS_F
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* FORM out
*---------------------------------------------------------------------*
FORM out.
CLEAR: lc, stack_out, so, otstup.
REFRESH stack_out.
otstup = st_width * 4.
stack_out[] = stack[].
CASE cur_fig-name+0(3).
WHEN 'SQU'.
w_typ ='1'.
WHEN 'LIN'.
w_typ ='2'.
WHEN 'RZZ'.
w_typ ='3'.
WHEN 'LZZ'.
w_typ ='4'.
WHEN 'TRI'.
w_typ ='5'.
WHEN 'LGG'.
w_typ ='6'.
WHEN 'RGG'.
w_typ ='7'.
ENDCASE.
MODIFY stack_out FROM w_typ INDEX cur_fig-body1.
MODIFY stack_out FROM w_typ INDEX cur_fig-body2.
MODIFY stack_out FROM w_typ INDEX cur_fig-body3.
MODIFY stack_out FROM w_typ INDEX cur_fig-body4.
WRITE: AT 30 '得分: ', scores.
SKIP 1.
WRITE /30 '下一个方块'.
SKIP 1.
NEW-LINE.
WRITE AT 30 nxt1.
PERFORM draw_next_fig USING nxt1.
NEW-LINE.
WRITE AT 30 nxt2.
PERFORM draw_next_fig USING nxt2.
NEW-LINE.
WRITE AT 30 nxt3.
PERFORM draw_next_fig USING nxt3.
SKIP TO LINE 3.
CLEAR outstring.
LOOP AT stack_out INTO st.
IF sy-tabix LE otstup.
CONTINUE.
ENDIF.
lc = sy-tabix MOD st_width.
CASE st.
WHEN ','. so = '::'.
WHEN 'O'. so = '##'.
WHEN '1'. so = '11'.
WHEN '2'. so = '22'.
WHEN '3'. so = '33'.
WHEN '4'. so = '44'.
WHEN '5'. so = '55'.
WHEN '6'. so = '66'.
WHEN '7'. so = '77'.
ENDCASE.
CONCATENATE outstring so INTO outstring.
IF lc = 0.
NEW-LINE.
TRANSLATE outstring USING ': '.
FORMAT COLOR 3 INTENSIFIED OFF.
WRITE (24) outstring.
DO 24 TIMES.
FORMAT COLOR 3 INTENSIFIED ON.
w_1st = syst-index + 1.
CASE outstring+syst-index(1).
WHEN '1'.
WRITE AT w_1st '_' COLOR = '01'.
WHEN '2'.
WRITE AT w_1st '_' COLOR = '02'.
WHEN '3'.
WRITE AT w_1st '_' COLOR = '03'.
WHEN '4'.
WRITE AT w_1st '_' COLOR = '04'.
WHEN '5'.
WRITE AT w_1st '_' COLOR = '05'.
WHEN '6'.
WRITE AT w_1st '_' COLOR = '06'.
WHEN '7'.
WRITE AT w_1st '_' COLOR = '07'.
ENDCASE.
ENDDO.
CLEAR outstring.
ENDIF.
ENDLOOP.
ENDFORM.
*---------------------------------------------------------------------*
* FORM draw_next_fig
*---------------------------------------------------------------------*
FORM draw_next_fig USING nextfig.
DATA: w_ind LIKE syst-index.
DO 8 TIMES.
w_1st = syst-index + 29.
w_ind = syst-index - 1.
CASE nextfig+w_ind(1).
WHEN '1'.
WRITE AT w_1st '_' COLOR = '01'.
WHEN '2'.
WRITE AT w_1st '_' COLOR = '02'.
WHEN '3'.
WRITE AT w_1st '_' COLOR = '03'.
WHEN '4'.
WRITE AT w_1st '_' COLOR = '04'.
WHEN '5'.
WRITE AT w_1st '_' COLOR = '05'.
WHEN '6'.
WRITE AT w_1st '_' COLOR = '06'.
WHEN '7'.
WRITE AT w_1st '_' COLOR = '07'.
ENDCASE.
ENDDO.
ENDFORM.
*---------------------------------------------------------------------*
* Form F_CALL_RFC_WAIT
*---------------------------------------------------------------------*
FORM f_call_rfc_wait.
DATA seconds TYPE i.
seconds = '1'.
CLEAR lv_mssg1.
CALL FUNCTION 'KKPA_RFC_PING_AND_WAIT' STARTING NEW TASK '001'
PERFORMING f_task_end ON END OF TASK
EXPORTING
seconds = seconds "Refresh time
EXCEPTIONS
RESOURCE_FAILURE = 1
communication_failure = 2 MESSAGE lv_mssg1
system_failure = 3 MESSAGE lv_mssg1
OTHERS = 4.
SET USER-COMMAND 'PF25'.
ENDFORM. " F_CALL_RFC_WAIT
*---------------------------------------------------------------------*
* Form F_TASK_END
*---------------------------------------------------------------------*
FORM f_task_end USING u_taskname.
CLEAR lv_mssg2.
RECEIVE RESULTS FROM FUNCTION 'KKPA_RFC_PING_AND_WAIT'
EXCEPTIONS
RESOURCE_FAILURE = 1
communication_failure = 2 MESSAGE lv_mssg2
system_failure = 3 MESSAGE lv_mssg2
OTHERS = 4.
CHECK sy-subrc EQ 0.
SET USER-COMMAND 'PF26'. " down
ENDFORM. " F_TASK_END
*---------------------------------------------------------------------*
* FORM init_figures *
*---------------------------------------------------------------------*
FORM init_figures.
CLEAR: wini, sini.
wini = st_width.
sini = wini DIV 2.
PERFORM init_square.
PERFORM init_line.
PERFORM right_zigzag.
PERFORM left_zigzag.
PERFORM init_t_piece.
PERFORM init_right_leg.
PERFORM init_left_leg.
ENDFORM.
*---------------------------------------------------------------------*
* FORM init_square *
*---------------------------------------------------------------------*
FORM init_square.
square-name = 'SQUARE'. "Square
square-body1 = sini.
square-body2 = sini + 1.
square-body3 = sini + wini.
square-body4 = sini + wini + 1.
square-width = 2.
square-height = 2.
ENDFORM.
*---------------------------------------------------------------------*
* FORM init_line *
*---------------------------------------------------------------------*
FORM init_line.
line1-name = 'LINE1'. "Line1
line1-body1 = sini - 2.
line1-body2 = sini - 1.
line1-body3 = sini .
line1-body4 = sini + 1.
line1-width = 4.
line1-height = 1.
line2-name = 'LINE2'. "line2
line2-body1 = sini .
line2-body2 = sini + wini.
line2-body3 = sini + wini + wini.
line2-body4 = sini + wini + wini + wini.
line2-width = 1.
line2-height = 4.
ENDFORM.
*---------------------------------------------------------------------*
* FORM left_zigzag *
*---------------------------------------------------------------------*
FORM left_zigzag.
lzz1-name = 'LZZ1'. "Left Zig Zag1
lzz1-body1 = sini .
lzz1-body2 = sini + wini.
lzz1-body3 = sini + 1 + wini.
lzz1-body4 = sini + 1 + wini + wini.
lzz1-width = 2.
lzz1-height = 3.
lzz2-name = 'LZZ2'. "Left Zig Zag2
lzz2-body1 = sini .
lzz2-body2 = sini + 1.
lzz2-body3 = sini + wini - 1.
lzz2-body4 = sini + wini.
lzz2-width = 3.
lzz2-height = 2.
ENDFORM.
*---------------------------------------------------------------------*
* FORM right_zigzag *
*---------------------------------------------------------------------*
FORM right_zigzag.
rzz1-name = 'RZZ1'. "Right Zig Zag1
rzz1-body1 = sini + 1.
rzz1-body2 = sini + wini .
rzz1-body3 = sini + wini + 1.
rzz1-body4 = sini + wini + wini.
rzz1-width = 2.
rzz1-height = 3.
rzz2-name = 'RZZ2'. "Right Zig Zag2
rzz2-body1 = sini - 1.
rzz2-body2 = sini .
rzz2-body3 = sini + wini.
rzz2-body4 = sini + 1 + wini.
rzz2-width = 3.
rzz2-height = 2.
ENDFORM.
*---------------------------------------------------------------------*
* FORM init_t_piece *
*---------------------------------------------------------------------*
FORM init_t_piece.
tri1-name = 'TRI1'. "T-Piece1
tri1-body1 = sini .
tri1-body2 = sini + wini - 1.
tri1-body3 = sini + wini.
tri1-body4 = sini + 1 + wini.
tri1-width = 3.
tri1-height = 2.
tri2-name = 'TRI2'. "T-Piece2
tri2-body1 = sini - 1.
tri2-body2 = sini + wini - 1.
tri2-body3 = sini + wini.
tri2-body4 = sini - 1 + wini + wini.
tri2-width = 2.
tri2-height = 3.
tri3-name = 'TRI3'. "T-Piece3
tri3-body1 = sini - 1.
tri3-body2 = sini .
tri3-body3 = sini + 1.
tri3-body4 = sini + wini.
tri3-width = 3.
tri3-height = 2.
tri4-name = 'TRI4'. "T-Piece4
tri4-body1 = sini .
tri4-body2 = sini - 1 + wini.
tri4-body3 = sini + wini.
tri4-body4 = sini + wini + wini.
tri4-width = 2.
tri4-height = 3.
ENDFORM.
*---------------------------------------------------------------------*
* FORM init_right_leg *
*---------------------------------------------------------------------*
FORM init_right_leg.
rgg1-name = 'RGG1'. "Right Leg1
rgg1-body1 = sini + 1.
rgg1-body2 = sini + wini + 1.
rgg1-body3 = sini + wini + wini .
rgg1-body4 = sini + wini + wini + 1.
rgg1-width = 2.
rgg1-height = 3.
rgg2-name = 'RGG2'. "Right Leg2
rgg2-body1 = sini - 1.
rgg2-body2 = sini + wini - 1.
rgg2-body3 = sini + wini.
rgg2-body4 = sini + wini + 1.
rgg2-width = 2.
rgg2-height = 3.
rgg3-name = 'RGG3'. "Right Leg3
rgg3-body1 = sini .
rgg3-body2 = sini + 1.
rgg3-body3 = sini + wini .
rgg3-body4 = sini + wini + wini.
rgg3-width = 2.
rgg3-height = 3.
rgg4-name = 'RGG4'. "Right Leg4
rgg4-body1 = sini - 1.
rgg4-body2 = sini .
rgg4-body3 = sini + 1.
rgg4-body4 = sini + wini + 1.
rgg4-width = 2.
rgg4-height = 3.
ENDFORM.
*---------------------------------------------------------------------*
* FORM init_left_leg *
*---------------------------------------------------------------------*
FORM init_left_leg.
lgg1-name = 'LGG1'. "Left Leg1
lgg1-body1 = sini .
lgg1-body2 = sini + wini.
lgg1-body3 = sini + wini + wini.
lgg1-body4 = sini + wini + wini + 1.
lgg1-width = 2.
lgg1-height = 3.
lgg2-name = 'LGG2'. "Left Leg2
lgg2-body1 = sini - 1.
lgg2-body2 = sini .
lgg2-body3 = sini + 1.
lgg2-body4 = sini + wini - 1.
lgg2-width = 2.
lgg2-height = 3.
lgg3-name = 'LGG3'. "Left Leg3
lgg3-body1 = sini .
lgg3-body2 = sini + 1.
lgg3-body3 = sini + wini + 1.
lgg3-body4 = sini + wini + wini + 1.
lgg3-width = 2.
lgg3-height = 3.
lgg4-name = 'LGG4'. "Left Leg4
lgg4-body1 = sini + 1.
lgg4-body2 = sini - 1 + wini.
lgg4-body3 = sini + wini.
lgg4-body4 = sini + wini + 1.
lgg4-width = 2.
lgg4-height = 3.
ENDFORM.
*---------------------------------------------------------------------*
* FORM init_stack *
*---------------------------------------------------------------------*
FORM init_stack.
CLEAR: size_v, size_h.
CLEAR: scores, result.
size_v = st_height + 4 .
size_h = st_width - 2.
CLEAR stack.
DO size_v TIMES.
APPEND 'O' TO stack.
DO size_h TIMES.
APPEND ',' TO stack.
ENDDO.
APPEND 'O' TO stack.
ENDDO.
APPEND ',' TO stack.
DO size_h TIMES.
APPEND 'O' TO stack.
ENDDO.
APPEND ',' TO stack.
ENDFORM.
*---------------------------------------------------------------------*
* FORM put_next_fig *
*---------------------------------------------------------------------*
FORM put_next_fig.
CLEAR: rnd.
CLEAR: err, result, answer.
IF ini IS INITIAL.
PERFORM random_integer USING ini cur_fig.
PERFORM random_integer USING rnd nxt_fig.
ELSE.
cur_fig = nxt_fig.
PERFORM random_integer USING rnd nxt_fig.
ENDIF.
PERFORM build_next_fig USING rnd.
PERFORM fig_move USING 'INIT' CHANGING err.
IF NOT err IS INITIAL.
WRITE scores TO result.
CONDENSE result.
CONCATENATE 'You score:' result INTO result SEPARATED BY space.
CALL FUNCTION 'POPUP_TO_CONFIRM_WITH_MESSAGE'
EXPORTING
defaultoption = 'Y'
diagnosetext1 = result
textline1 = 'Play again?'
titel = 'GAME OVER'
cancel_display = ''
IMPORTING
answer = answer.
IF answer EQ 'N'.
LEAVE PROGRAM.
ELSE.
PERFORM init_stack.
PERFORM put_next_fig.
ENDIF.
ENDIF.
ENDFORM.
*---------------------------------------------------------------------*
* FORM random_integer *
*---------------------------------------------------------------------*
FORM random_integer USING i_num i_fig.
CALL FUNCTION 'QF05_RANDOM_INTEGER'
EXPORTING
ran_int_max = 7
ran_int_min = 1
IMPORTING
ran_int = i_num.
CASE i_num.
WHEN '1'.
i_fig = square.
WHEN '2'.
i_fig = line1.
WHEN '3'.
i_fig = rzz1.
WHEN '4'.
i_fig = lzz1.
WHEN '5'.
i_fig = tri1.
WHEN '6'.
i_fig = lgg1.
WHEN '7'.
i_fig = rgg1.
ENDCASE.
ENDFORM.
*---------------------------------------------------------------------*
* Form build_next_fig
*---------------------------------------------------------------------*
FORM build_next_fig USING p_fig.
CLEAR: nxt1, nxt2, nxt3.
CASE p_fig.
WHEN '1'.
nxt1+0(4) = '1111'.
nxt2+0(4) = '1111'.
WHEN '2'.
nxt1+0(8) = '22222222'.
WHEN '3'.
nxt1+2(2) = '33'.
nxt2+0(4) = '3333'.
nxt3+0(2) = '33'.
WHEN '4'.
nxt1+0(2) = '44'.
nxt2+0(4) = '4444'.
nxt3+2(2) = '44'.
WHEN '5'.
nxt1+2(2) = '55'.
nxt2+0(6) = '555555'.
WHEN '6'.
nxt1+0(2) = '66'.
nxt2+0(2) = '66'.
nxt3+0(4) = '6666'.
WHEN '7'.
nxt1+2(2) = '77'.
nxt2+2(2) = '77'.
nxt3+0(4) = '7777'.
ENDCASE.
ENDFORM. " build_next_fig
*---------------------------------------------------------------------*
* FORM fig_move *
*---------------------------------------------------------------------*
FORM fig_move USING dir TYPE char5 CHANGING error.
CLEAR: temp_fig, shft1.
error = ''.
temp_fig = cur_fig.
CASE dir.
WHEN 'DOWN'.
shft1 = st_width.
WHEN 'LEFT'.
shft1 = -1.
WHEN 'RIGHT'.
shft1 = 1.
WHEN 'INIT'.
shft1 = st_width * 4.
ENDCASE.
ADD shft1 TO cur_fig-body1.
ADD shft1 TO cur_fig-body2.
ADD shft1 TO cur_fig-body3.
ADD shft1 TO cur_fig-body4.
PERFORM check_pos CHANGING error.
IF NOT error IS INITIAL.
cur_fig = temp_fig.
ENDIF.
ENDFORM.
*---------------------------------------------------------------------*
* FORM check_pos
*---------------------------------------------------------------------*
FORM check_pos CHANGING error TYPE char1.
DO 1 TIMES.
READ TABLE stack INTO st INDEX cur_fig-body1.
IF st NE ','.
error = 'X'. EXIT.
ENDIF.
READ TABLE stack INTO st INDEX cur_fig-body2.
IF st NE ','.
error = 'X'. EXIT.
ENDIF.
READ TABLE stack INTO st INDEX cur_fig-body3.
IF st NE ','.
error = 'X'. EXIT.
ENDIF.
READ TABLE stack INTO st INDEX cur_fig-body4.
IF st NE ','.
error = 'X'. EXIT.
ENDIF.
ENDDO.
ENDFORM.
*---------------------------------------------------------------------*
* FORM fig_rotate
*---------------------------------------------------------------------*
FORM fig_rotate.
CLEAR: start, temp_fig1, err1, shft, w1, w2.
w1 = st_width.
w2 = st_width DIV 2.
temp_fig1 = cur_fig.
start = cur_fig-body1.
CASE temp_fig1-name.
WHEN 'LINE1'.
cur_fig = line2.
shft = - ( w1 * 2 + w2 - 2 ) .
WHEN 'LINE2'.
cur_fig = line1.
shft = w1 * 2 - w2 .
WHEN 'LZZ1'.
cur_fig = lzz2.
shft = w1 - w2 .
WHEN 'LZZ2'.
cur_fig = lzz1.
shft = w2 - w1 - w1 .
WHEN 'RZZ1'.
cur_fig = rzz2.
shft = w1 - w2 - 1 .
WHEN 'RZZ2'.
cur_fig = rzz1.
shft = w2 - w1 - w1 + 1.
WHEN 'TRI1'.
cur_fig = tri2.
shft = - w2 + 1 .
WHEN 'TRI2'.
cur_fig = tri3.
shft = w1 - w2 .
WHEN 'TRI3'.
cur_fig = tri4.
shft = - w1 - w2 + 1 .
WHEN 'TRI4'.
cur_fig = tri1.
shft = - w2 .
WHEN 'LGG1'.
cur_fig = lgg2.
shft = - w2 + 1 .
WHEN 'LGG2'.
cur_fig = lgg3.
shft = - w2 .
WHEN 'LGG3'.
cur_fig = lgg4.
shft = - w2 .
WHEN 'LGG4'.
cur_fig = lgg1.
shft = - w2 - 1 .
WHEN 'RGG1'.
cur_fig = rgg2.
shft = - w2 .
WHEN 'RGG2'.
cur_fig = rgg3.
shft = - w2 .
WHEN 'RGG3'.
cur_fig = rgg4.
shft = - w2 + 1 .
WHEN 'RGG4'.
cur_fig = rgg1.
shft = - w2 .
WHEN 'SQUARE'.
cur_fig = square.
shft = - st_width DIV 2 .
ENDCASE.
cur_fig-body1 = start + cur_fig-body1 + shft. "- temp_fig1-body1.
cur_fig-body2 = start + cur_fig-body2 + shft. "- temp_fig1-body2.
cur_fig-body3 = start + cur_fig-body3 + shft. "- temp_fig1-body3.
cur_fig-body4 = start + cur_fig-body4 + shft. "- temp_fig1-body4.
PERFORM check_pos CHANGING err1.
IF err1 = 'X'.
cur_fig = temp_fig1.
ENDIF.
ENDFORM.
*---------------------------------------------------------------------*
* FORM fig_append
*---------------------------------------------------------------------*
FORM fig_append.
MODIFY stack FROM w_typ INDEX cur_fig-body1.
MODIFY stack FROM w_typ INDEX cur_fig-body2.
MODIFY stack FROM w_typ INDEX cur_fig-body3.
MODIFY stack FROM w_typ INDEX cur_fig-body4.
ENDFORM.
*---------------------------------------------------------------------*
* FORM check_full_line
*---------------------------------------------------------------------*
FORM check_full_line.
CLEAR: cl, n1, n2, outst, ix, s10, sw, linct.
sw = st_width - 2.
CLEAR outst.
LOOP AT stack INTO st.
linct = sy-tabix MOD st_width .
IF linct = 1.
ix = sy-tabix.
s10 = ix + st_width - 1.
ENDIF.
CONCATENATE outst st INTO outst.
IF linct = 0.
SEARCH outst FOR ','.
IF sy-subrc NE 0.
DELETE stack FROM ix TO s10.
ADD 1 TO cl.
ENDIF.
CLEAR outst.
ENDIF.
ENDLOOP.
CLEAR: n1, n2.
DO cl TIMES.
ADD 10 TO n1.
ADD n1 TO n2.
INSERT 'O' INTO stack INDEX 1.
DO sw TIMES.
INSERT ',' INTO stack INDEX 1.
ENDDO.
INSERT 'O' INTO stack INDEX 1.
ENDDO.
ADD n2 TO scores.
ENDFORM.
include ZTETRIS_I 代码:
*---------------------------------------------------------------------*
* INCLUDE ZTETRIS_I
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* MODULE exx INPUT
*---------------------------------------------------------------------*
MODULE exx INPUT.
LEAVE PROGRAM.
ENDMODULE.
include ZTETRIS_O 代码:
*---------------------------------------------------------------------*
* INCLUDE ZTETRIS_O
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* MODULE status_0100 OUTPUT
*---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
PERFORM out.
LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 100.
LEAVE SCREEN.
ENDMODULE.
新建一个 id 为 100 的 dynpro screen:
新建一个 PF STATUS:
function key 明细如下:
更多Jerry的原创文章,尽在:"汪子熙":